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

Function GetPreviousNonBlankLine

scripts/cpp_lint.py:3050–3070  ·  view source on GitHub ↗

Return the most recent non-blank line and its line number. Args: clean_lines: A CleansedLines instance containing the file contents. linenum: The number of the line to check. Returns: A tuple with two elements. The first element is the contents of the last non-blank line befor

(clean_lines, linenum)

Source from the content-addressed store, hash-verified

3048
3049
3050def GetPreviousNonBlankLine(clean_lines, linenum):
3051 """Return the most recent non-blank line and its line number.
3052
3053 Args:
3054 clean_lines: A CleansedLines instance containing the file contents.
3055 linenum: The number of the line to check.
3056
3057 Returns:
3058 A tuple with two elements. The first element is the contents of the last
3059 non-blank line before the current line, or the empty string if this is the
3060 first non-blank line. The second is the line number of that line, or -1
3061 if this is the first non-blank line.
3062 """
3063
3064 prevlinenum = linenum - 1
3065 while prevlinenum >= 0:
3066 prevline = clean_lines.elided[prevlinenum]
3067 if not IsBlankLine(prevline): # if not a blank line...
3068 return (prevline, prevlinenum)
3069 prevlinenum -= 1
3070 return ('', -1)
3071
3072
3073def CheckBraces(filename, clean_lines, linenum, error):

Callers 2

CheckBracesFunction · 0.85
CheckStyleFunction · 0.85

Calls 1

IsBlankLineFunction · 0.85

Tested by

no test coverage detected