Mercurial > public > mercurial-scm > hg-stable
diff hgext/highlight/highlight.py @ 43077:687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Done with
python3.7 contrib/byteify-strings.py -i $(hg files 'set:mercurial/**.py - mercurial/thirdparty/** + hgext/**.py - hgext/fsmonitor/pywatchman/** - mercurial/__init__.py')
black -l 80 -t py33 -S $(hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**" - hgext/fsmonitor/pywatchman/**')
# skip-blame mass-reformatting only
Differential Revision: https://phab.mercurial-scm.org/D6972
author | Augie Fackler <augie@google.com> |
---|---|
date | Sun, 06 Oct 2019 09:48:39 -0400 |
parents | 2372284d9457 |
children | 8ff1ecfadcd1 |
line wrap: on
line diff
--- a/hgext/highlight/highlight.py Sun Oct 06 09:45:02 2019 -0400 +++ b/hgext/highlight/highlight.py Sun Oct 06 09:48:39 2019 -0400 @@ -12,7 +12,7 @@ from mercurial import demandimport -demandimport.IGNORES.update(['pkgutil', 'pkg_resources', '__main__']) +demandimport.IGNORES.update([b'pkgutil', b'pkg_resources', b'__main__']) from mercurial import ( encoding, @@ -39,27 +39,27 @@ HtmlFormatter = pygments.formatters.HtmlFormatter SYNTAX_CSS = ( - '\n<link rel="stylesheet" href="{url}highlightcss" ' 'type="text/css" />' + b'\n<link rel="stylesheet" href="{url}highlightcss" ' b'type="text/css" />' ) def pygmentize(field, fctx, style, tmpl, guessfilenameonly=False): # append a <link ...> to the syntax highlighting css - tmpl.load('header') - old_header = tmpl.cache['header'] + tmpl.load(b'header') + old_header = tmpl.cache[b'header'] if SYNTAX_CSS not in old_header: new_header = old_header + SYNTAX_CSS - tmpl.cache['header'] = new_header + tmpl.cache[b'header'] = new_header text = fctx.data() if stringutil.binary(text): return # str.splitlines() != unicode.splitlines() because "reasons" - for c in "\x0c\x1c\x1d\x1e": + for c in b"\x0c\x1c\x1d\x1e": if c in text: - text = text.replace(c, '') + text = text.replace(c, b'') # Pygments is best used with Unicode strings: # <http://pygments.org/docs/unicode/> @@ -94,8 +94,8 @@ for s in colorized.splitlines() ) - tmpl._filters['colorize'] = lambda x: next(coloriter) + tmpl._filters[b'colorize'] = lambda x: next(coloriter) oldl = tmpl.cache[field] - newl = oldl.replace('line|escape', 'line|colorize') + newl = oldl.replace(b'line|escape', b'line|colorize') tmpl.cache[field] = newl