comparison mercurial/encoding.py @ 43787:be8552f25cab

cleanup: fix docstring formatting This is just removing the b'' prefix (except demandimportpy2), and making sure it is triple quoted. I skipped the mapping.py module in zope because that's 3rd party code. Differential Revision: https://phab.mercurial-scm.org/D7539
author Matt Harbison <matt_harbison@yahoo.com>
date Sun, 01 Dec 2019 18:46:10 -0500
parents 7b14d649af1b
children 9d2b2df2c2ba
comparison
equal deleted inserted replaced
43786:421ea5772039 43787:be8552f25cab
310 ) 310 )
311 311
312 312
313 def colwidth(s): 313 def colwidth(s):
314 # type: (bytes) -> int 314 # type: (bytes) -> int
315 b"Find the column width of a string for display in the local encoding" 315 """Find the column width of a string for display in the local encoding"""
316 return ucolwidth(s.decode(_sysstr(encoding), 'replace')) 316 return ucolwidth(s.decode(_sysstr(encoding), 'replace'))
317 317
318 318
319 def ucolwidth(d): 319 def ucolwidth(d):
320 # type: (Text) -> int 320 # type: (Text) -> int
321 b"Find the column width of a Unicode string for display" 321 """Find the column width of a Unicode string for display"""
322 eaw = getattr(unicodedata, 'east_asian_width', None) 322 eaw = getattr(unicodedata, 'east_asian_width', None)
323 if eaw is not None: 323 if eaw is not None:
324 return sum([eaw(c) in _wide and 2 or 1 for c in d]) 324 return sum([eaw(c) in _wide and 2 or 1 for c in d])
325 return len(d) 325 return len(d)
326 326
434 return ellipsis # no enough room for multi-column characters 434 return ellipsis # no enough room for multi-column characters
435 435
436 436
437 def lower(s): 437 def lower(s):
438 # type: (bytes) -> bytes 438 # type: (bytes) -> bytes
439 b"best-effort encoding-aware case-folding of local string s" 439 """best-effort encoding-aware case-folding of local string s"""
440 try: 440 try:
441 return asciilower(s) 441 return asciilower(s)
442 except UnicodeDecodeError: 442 except UnicodeDecodeError:
443 pass 443 pass
444 try: 444 try:
457 raise error.Abort(k, hint=b"please check your locale settings") 457 raise error.Abort(k, hint=b"please check your locale settings")
458 458
459 459
460 def upper(s): 460 def upper(s):
461 # type: (bytes) -> bytes 461 # type: (bytes) -> bytes
462 b"best-effort encoding-aware case-folding of local string s" 462 """best-effort encoding-aware case-folding of local string s"""
463 try: 463 try:
464 return asciiupper(s) 464 return asciiupper(s)
465 except UnicodeDecodeError: 465 except UnicodeDecodeError:
466 return upperfallback(s) 466 return upperfallback(s)
467 467