Skip to content

Commit

Permalink
[py_vulcanize] Python 3.12 compatibility tweaks
Browse files Browse the repository at this point in the history
Bug: chromium:1487454
Change-Id: If8e6fddf0a21ecf5c92e48b3cc0c3ffd7f3d6f9a
Reviewed-on: https://chromium-review.googlesource.com/c/catapult/+/5092511
Auto-Submit: Ho Cheung <[email protected]>
Reviewed-by: John Chen <[email protected]>
Commit-Queue: John Chen <[email protected]>
  • Loading branch information
gz83 authored and Catapult LUCI CQ committed Dec 6, 2023
1 parent 8cf7c46 commit 2742d1d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def GetHTMLForStylesheetHRef(self, href): # pylint: disable=unused-argument

def GetHTMLForInlineStylesheet(self, contents):
if self.current_module is None:
if re.search('url\(.+\)', contents):
if re.search(r'url\(.+\)', contents):
raise Exception(
'Default HTMLGenerationController cannot handle inline style urls')
return contents
Expand Down
2 changes: 1 addition & 1 deletion common/py_vulcanize/py_vulcanize/js_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@


def EscapeJSIfNeeded(js):
return js.replace('</script>', '<\/script>')
return js.replace('</script>', r'<\/script>')
2 changes: 1 addition & 1 deletion common/py_vulcanize/py_vulcanize/parse_html_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,6 @@ def Parse(self, html):
html = ''
else:
if html.find('< /script>') != -1:
raise Exception('Escape script tags with <\/script>')
raise Exception(r'Escape script tags with <\/script>')

return HTMLModuleParserResults(html)
4 changes: 2 additions & 2 deletions common/py_vulcanize/py_vulcanize/style_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def InlineUrl(m):
return 'url(data:image/%s;base64,%s)' % (ext[1:], data.decode('utf-8'))

# I'm assuming we only have url()'s associated with images
return re.sub('url\((?P<quote>"|\'|)(?P<url>[^"\'()]*)(?P=quote)\)',
return re.sub(r'url\((?P<quote>"|\'|)(?P<url>[^"\'()]*)(?P=quote)\)',
InlineUrl, self.contents)

def AppendDirectlyDependentFilenamesTo(self, dependent_filenames):
Expand All @@ -72,7 +72,7 @@ def _Load(self, containing_dirname):
raise Exception('@imports are not supported')

matches = re.findall(
'url\((?:["|\']?)([^"\'()]*)(?:["|\']?)\)',
r'url\((?:["|\']?)([^"\'()]*)(?:["|\']?)\)',
self.contents)

def resolve_url(url):
Expand Down

0 comments on commit 2742d1d

Please sign in to comment.