Fill up the include_dict with new includes found from the file. Args: filename: the name of the header to read. include_dict: a dictionary in which the headers are inserted. io: The io factory to use to read the file. Provided for testability. Returns: True if a header was succ
(filename, include_dict, io=codecs)
| 5394 | |
| 5395 | |
| 5396 | def UpdateIncludeState(filename, include_dict, io=codecs): |
| 5397 | """Fill up the include_dict with new includes found from the file. |
| 5398 | |
| 5399 | Args: |
| 5400 | filename: the name of the header to read. |
| 5401 | include_dict: a dictionary in which the headers are inserted. |
| 5402 | io: The io factory to use to read the file. Provided for testability. |
| 5403 | |
| 5404 | Returns: |
| 5405 | True if a header was successfully added. False otherwise. |
| 5406 | """ |
| 5407 | headerfile = None |
| 5408 | try: |
| 5409 | headerfile = io.open(filename, 'r', 'utf8', 'replace') |
| 5410 | except IOError: |
| 5411 | return False |
| 5412 | linenum = 0 |
| 5413 | for line in headerfile: |
| 5414 | linenum += 1 |
| 5415 | clean_line = CleanseComments(line) |
| 5416 | match = _RE_PATTERN_INCLUDE.search(clean_line) |
| 5417 | if match: |
| 5418 | include = match.group(2) |
| 5419 | include_dict.setdefault(include, linenum) |
| 5420 | return True |
| 5421 | |
| 5422 | |
| 5423 | def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error, |
no test coverage detected