MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / UpdateIncludeState

Function UpdateIncludeState

rtpose_wrapper/scripts/cpp_lint.py:4454–4480  ·  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

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

Callers 1

Calls 2

CleanseCommentsFunction · 0.85
openMethod · 0.80

Tested by

no test coverage detected