Message ID | 20230203101457.525922-1-juerg.haefliger@canonical.com |
---|---|
State | New |
Headers | show |
Series | [Unstable/lunar] UBUNTU: [Packaging] annotations: Handle single-line annoation rules | expand |
Doesn't apply due to local commit. Will resend. ...Juerg > The old annotations file allowed single-line rules such as: > CONFIG_FOO policy<'amd64': 'n'> note<LP: #123456> > > The new annotations parser doesn't support that, so add it. > > Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com> > --- > debian/scripts/misc/kconfig/annotations.py | 26 +++++++++++++--------- > 1 file changed, 15 insertions(+), 11 deletions(-) > > diff --git a/debian/scripts/misc/kconfig/annotations.py b/debian/scripts/misc/kconfig/annotations.py > index 2f5fd19dd6d7..2bbc1413aeed 100644 > --- a/debian/scripts/misc/kconfig/annotations.py > +++ b/debian/scripts/misc/kconfig/annotations.py > @@ -56,8 +56,8 @@ class Annotation(Config): > # Convert multiple spaces to single space to simplifly parsing > data = re.sub(r' *', ' ', data) > > - # Handle includes (recursively) > for line in data.splitlines(): > + # Handle includes (recursively) > m = re.match(r'^include\s+"?([^"]*)"?', line) > if m: > self.include.append(m.group(1)) > @@ -65,24 +65,28 @@ class Annotation(Config): > include_data = self._load(include_fname) > self._parse_body(include_data) > else: > - # Skip empty, non-policy and non-note lines > - if re.match('.* policy<', line) or re.match('.* note<', line): > + # Handle policy and note lines > + if re.match(r'.* (policy|note)<', line): > try: > - # Parse single policy or note rule > conf = line.split(' ')[0] > if conf in self.config: > entry = self.config[conf] > else: > entry = {'policy': {}} > - m = re.match(r'.*policy<(.*?)>', line) > + > + match = False > + m = re.match(r'.* policy<(.*?)>', line) > if m: > + match = True > entry['policy'] |= literal_eval(m.group(1)) > - else: > - m = re.match(r'.*note<(.*?)>', line) > - if m: > - entry['note'] = "'" + m.group(1).replace("'", '') + "'" > - else: > - raise Exception('syntax error') > + > + m = re.match(r'.* note<(.*?)>', line) > + if m: > + match = True > + entry['note'] = "'" + m.group(1).replace("'", '') + "'" > + > + if not match: > + raise Exception('syntax error') > self.config[conf] = entry > except Exception as e: > raise Exception(str(e) + f', line = {line}')
diff --git a/debian/scripts/misc/kconfig/annotations.py b/debian/scripts/misc/kconfig/annotations.py index 2f5fd19dd6d7..2bbc1413aeed 100644 --- a/debian/scripts/misc/kconfig/annotations.py +++ b/debian/scripts/misc/kconfig/annotations.py @@ -56,8 +56,8 @@ class Annotation(Config): # Convert multiple spaces to single space to simplifly parsing data = re.sub(r' *', ' ', data) - # Handle includes (recursively) for line in data.splitlines(): + # Handle includes (recursively) m = re.match(r'^include\s+"?([^"]*)"?', line) if m: self.include.append(m.group(1)) @@ -65,24 +65,28 @@ class Annotation(Config): include_data = self._load(include_fname) self._parse_body(include_data) else: - # Skip empty, non-policy and non-note lines - if re.match('.* policy<', line) or re.match('.* note<', line): + # Handle policy and note lines + if re.match(r'.* (policy|note)<', line): try: - # Parse single policy or note rule conf = line.split(' ')[0] if conf in self.config: entry = self.config[conf] else: entry = {'policy': {}} - m = re.match(r'.*policy<(.*?)>', line) + + match = False + m = re.match(r'.* policy<(.*?)>', line) if m: + match = True entry['policy'] |= literal_eval(m.group(1)) - else: - m = re.match(r'.*note<(.*?)>', line) - if m: - entry['note'] = "'" + m.group(1).replace("'", '') + "'" - else: - raise Exception('syntax error') + + m = re.match(r'.* note<(.*?)>', line) + if m: + match = True + entry['note'] = "'" + m.group(1).replace("'", '') + "'" + + if not match: + raise Exception('syntax error') self.config[conf] = entry except Exception as e: raise Exception(str(e) + f', line = {line}')
The old annotations file allowed single-line rules such as: CONFIG_FOO policy<'amd64': 'n'> note<LP: #123456> The new annotations parser doesn't support that, so add it. Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com> --- debian/scripts/misc/kconfig/annotations.py | 26 +++++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-)