Mercurial > public > mercurial-scm > hg-stable
comparison doc/hgmanpage.py @ 52664:9db77d46de79
py3: drop redundant `u''` prefixes on string literals
Strings are unicode on Python 3. These were rewritten by `pyupgrade`.
It's arguably better to fix the `contrib` stuff upstream and then re-vendor it,
but I don't feel like waiting for that, and then all of the regression testing
involved to get a minor improvement in the codebase. It was last vendored 5
years ago, and will likely be a large change anyway to drop py2 support. Also,
we've already made minor formatting changes to it locally.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Mon, 06 Jan 2025 14:15:40 -0500 |
parents | ca7bde5dbafb |
children | f19a3f1437f3 |
comparison
equal
deleted
inserted
replaced
52663:dc36535a5edc | 52664:9db77d46de79 |
---|---|
281 ): | 281 ): |
282 self.body[i] = '.\n' | 282 self.body[i] = '.\n' |
283 return ''.join(self.head + self.body + self.foot) | 283 return ''.join(self.head + self.body + self.foot) |
284 | 284 |
285 def deunicode(self, text): | 285 def deunicode(self, text): |
286 text = text.replace(u'\xa0', '\\ ') | 286 text = text.replace('\xa0', '\\ ') |
287 text = text.replace(u'\u2020', '\\(dg') | 287 text = text.replace('\u2020', '\\(dg') |
288 return text | 288 return text |
289 | 289 |
290 def visit_Text(self, node): | 290 def visit_Text(self, node): |
291 text = node.astext() | 291 text = node.astext() |
292 text = text.replace('\\', '\\e') | 292 text = text.replace('\\', '\\e') |
293 replace_pairs = [ | 293 replace_pairs = [ |
294 (u'-', u'\\-'), | 294 ('-', '\\-'), |
295 (u"'", u'\\(aq'), | 295 ("'", '\\(aq'), |
296 (u'´', u"\\'"), | 296 ('´', "\\'"), |
297 (u'`', u'\\(ga'), | 297 ('`', '\\(ga'), |
298 ] | 298 ] |
299 for in_char, out_markup in replace_pairs: | 299 for in_char, out_markup in replace_pairs: |
300 text = text.replace(in_char, out_markup) | 300 text = text.replace(in_char, out_markup) |
301 # unicode | 301 # unicode |
302 text = self.deunicode(text) | 302 text = self.deunicode(text) |