layerindex: use raw strings for regular expressions
PATCH 1/3 layerindex: use raw strings for regular expressions
Fix the "invalid escape sequence" DeprecationWarnings reported by the test suite in models.py, utils.py and forms.py. Python 3.12 turns these into SyntaxWarnings and a future release will make them errors. The patterns themselves are unchanged.
AI-Generated: Claude Opus 5.5
--- layerindex/forms.py | 2 +- layerindex/models.py | 2 +- layerindex/utils.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
layerindex/forms.py +1 -1
@@ -136,7 +136,7 @@ class EditLayerForm(StyledModelForm): def clean_summary(self): # Compress whitespace and use only spaces summary = self.cleaned_data['summary'].strip() - summary = re.sub('\s+', ' ', summary) + summary = re.sub(r'\s+', ' ', summary) return summary def clean_layer_type(self):
layerindex/models.py +1 -1
@@ -278,7 +278,7 @@ class LayerBranch(models.Model): url = base_url.replace('%branch%', branchname) if path: splitpath = path.split('/') - for match in re.findall('(%pathelement\[([0-9]*)(:[0-9]*)?\]%)', url): + for match in re.findall(r'(%pathelement\[([0-9]*)(:[0-9]*)?\]%)', url): if match[1] == '': start = None else:
layerindex/utils.py +1 -1
@@ -528,7 +528,7 @@ def sanitise_html(html): return soup.renderContents() def squashspaces(string): - return re.sub("\s+", " ", string).strip() + return re.sub(r"\s+", " ", string).strip() def sha256_file(ifn): import hashlib
Signature · 1 line
2.56.0
PATCH 2/3 tools: use raw strings for regular expressions
Fix the remaining "invalid escape sequence" warnings in the layerindex and rrs tools, which the test suite does not import. Python 3.12 turns these into SyntaxWarnings and a future release will make them errors. The resulting pattern strings are unchanged.
AI-Generated: Claude Opus 5.5
--- layerindex/tools/import_layer.py | 2 +- layerindex/tools/import_otherdistro.py | 6 +++--- rrs/tools/common.py | 4 ++-- rrs/tools/rrs_maintainer_history.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-)
layerindex/tools/import_layer.py +1 -1
@@ -205,7 +205,7 @@ def get_layer_type_choices(): return (help_str, choices) def main(): - valid_layer_name = re.compile('[-\w]+$') + valid_layer_name = re.compile(r'[-\w]+$') parser = optparse.OptionParser( usage = """
layerindex/tools/import_otherdistro.py +3 -3
@@ -52,8 +52,8 @@ def update_recipe_file(path, recipe, repodir, raiseexceptions=False): # yes, yes, I know this is all crude as hell, but it gets the job done. # At the end of the day we are scraping the spec file, we aren't trying to build it - pnum_re = re.compile('-p[\s]*([0-9]+)') - configure_re = re.compile('[/%]configure\s') + pnum_re = re.compile(r'-p[\s]*([0-9]+)') + configure_re = re.compile(r'[/%]configure\s') try: logger.debug('Updating recipe %s' % path)
@@ -294,7 +294,7 @@ def update_recipe_file(path, recipe, repodir, raiseexceptions=False): patchsplit = line.split() if '-P' in line: # Old style - patchid = re.search('-P[\s]*([0-9]+)', line) + patchid = re.search(r'-P[\s]*([0-9]+)', line) if patchid: patchid = patchid.groups()[0] else:
rrs/tools/common.py +2 -2
@@ -146,7 +146,7 @@ def get_recipe_pv_without_srcpv(pv, uri_type): sfx = '' if uri_type == 'git': - git_regex = re.compile("(?P<pfx>(v|r|))(?P<ver>((\d+[\.\-_]*)+))(?P<sfx>(\+|)(git|)(r|)(AUTOINC|)(\+|))(?P<rev>.*)") + git_regex = re.compile(r"(?P<pfx>(v|r|))(?P<ver>((\d+[\.\-_]*)+))(?P<sfx>(\+|)(git|)(r|)(AUTOINC|)(\+|))(?P<rev>.*)") m = git_regex.match(pv) if m:
@@ -154,7 +154,7 @@ def get_recipe_pv_without_srcpv(pv, uri_type): pfx = m.group('pfx') sfx = m.group('sfx') else: - regex = re.compile("(?P<pfx>(v|r|))(?P<ver>((\w+[\.\-_]*)+))") + regex = re.compile(r"(?P<pfx>(v|r|))(?P<ver>((\w+[\.\-_]*)+))") m = regex.match(pv) if m: pv = m.group('ver')
rrs/tools/rrs_maintainer_history.py +1 -1
@@ -37,7 +37,7 @@ MAINTAINERS_INCLUDE_PATH = 'conf/distro/include/maintainers.inc' """ def get_recipe_maintainer(line, logger): import re - regex = re.compile('^RECIPE_MAINTAINER[:_]pn-(?P<pn>.*)\s=\s"(?P<name>.+) <(?P<email>.*)>"$') + regex = re.compile(r'^RECIPE_MAINTAINER[:_]pn-(?P<pn>.*)\s=\s"(?P<name>.+) <(?P<email>.*)>"$') match = regex.search(line) if match:
Signature · 1 line
2.56.0
PATCH 3/3 layerindex/bulkchange.py: fix syntax error in LayerItem import
In reply to Tim OrlingCommit c913725 ("update.py: Allow bitbake to live in a subdirectory of a repository") wrote "import layerindex.models import LayerItem", which is a SyntaxError, so bulkchange.py has failed to run since then. It is run by the bulk change patch download in views.py, so that download has been broken.
AI-Generated: Claude Opus 5.5
--- layerindex/bulkchange.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
layerindex/bulkchange.py +1 -1
@@ -101,7 +101,7 @@ def main(): branch = utils.get_branch('master') fetchdir = settings.LAYER_FETCH_DIR - import layerindex.models import LayerItem + from layerindex.models import LayerItem bitbakeitem = LayerItem() bitbakeitem.vcs_url = settings.BITBAKE_REPO_URL bitbakepath = os.path.join(fetchdir, bitbakeitem.get_fetch_dir())
Signature · 1 line
2.56.0