MCPcopy Create free account
hub / github.com/BVLC/caffe / GetLineWidth

Function GetLineWidth

scripts/cpp_lint.py:3441–3460  ·  view source on GitHub ↗

Determines the width of the line in column positions. Args: line: A string, which may be a Unicode string. Returns: The width of the line in column positions, accounting for Unicode combining characters and wide characters.

(line)

Source from the content-addressed store, hash-verified

3439
3440
3441def GetLineWidth(line):
3442 """Determines the width of the line in column positions.
3443
3444 Args:
3445 line: A string, which may be a Unicode string.
3446
3447 Returns:
3448 The width of the line in column positions, accounting for Unicode
3449 combining characters and wide characters.
3450 """
3451 if six.PY2:
3452 if isinstance(line, unicode):
3453 width = 0
3454 for uc in unicodedata.normalize('NFC', line):
3455 if unicodedata.east_asian_width(uc) in ('W', 'F'):
3456 width += 2
3457 elif not unicodedata.combining(uc):
3458 width += 1
3459 return width
3460 return len(line)
3461
3462
3463def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state,

Callers 1

CheckStyleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected