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

Function UpdateIncludeState

scripts/cpp_lint.py:4458–4484  ·  view source on GitHub ↗

Fill up the include_state with new includes found from the file. Args: filename: the name of the header to read. include_state: an _IncludeState instance in which the headers are inserted. io: The io factory to use to read the file. Provided for testability. Returns: True if a

(filename, include_state, io=codecs)

Source from the content-addressed store, hash-verified

4456
4457
4458def UpdateIncludeState(filename, include_state, io=codecs):
4459 """Fill up the include_state with new includes found from the file.
4460
4461 Args:
4462 filename: the name of the header to read.
4463 include_state: an _IncludeState instance in which the headers are inserted.
4464 io: The io factory to use to read the file. Provided for testability.
4465
4466 Returns:
4467 True if a header was successfully added. False otherwise.
4468 """
4469 headerfile = None
4470 try:
4471 headerfile = io.open(filename, 'r', 'utf8', 'replace')
4472 except IOError:
4473 return False
4474 linenum = 0
4475 for line in headerfile:
4476 linenum += 1
4477 clean_line = CleanseComments(line)
4478 match = _RE_PATTERN_INCLUDE.search(clean_line)
4479 if match:
4480 include = match.group(2)
4481 # The value formatting is cute, but not really used right now.
4482 # What matters here is that the key is in include_state.
4483 include_state.setdefault(include, '%s:%d' % (filename, linenum))
4484 return True
4485
4486
4487def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error,

Callers 1

Calls 1

CleanseCommentsFunction · 0.85

Tested by

no test coverage detected