@@ 5629-5653 (lines=25) @@ | ||
5626 | return files_belong_to_same_module, common_path |
|
5627 | ||
5628 | ||
5629 | def UpdateIncludeState(filename, include_dict, io=codecs): |
|
5630 | """Fill up the include_dict with new includes found from the file. |
|
5631 | ||
5632 | Args: |
|
5633 | filename: the name of the header to read. |
|
5634 | include_dict: a dictionary in which the headers are inserted. |
|
5635 | io: The io factory to use to read the file. Provided for testability. |
|
5636 | ||
5637 | Returns: |
|
5638 | True if a header was successfully added. False otherwise. |
|
5639 | """ |
|
5640 | headerfile = None |
|
5641 | try: |
|
5642 | headerfile = io.open(filename, 'r', 'utf8', 'replace') |
|
5643 | except IOError: |
|
5644 | return False |
|
5645 | linenum = 0 |
|
5646 | for line in headerfile: |
|
5647 | linenum += 1 |
|
5648 | clean_line = CleanseComments(line) |
|
5649 | match = _RE_PATTERN_INCLUDE.search(clean_line) |
|
5650 | if match: |
|
5651 | include = match.group(2) |
|
5652 | include_dict.setdefault(include, linenum) |
|
5653 | return True |
|
5654 | ||
5655 | ||
5656 | def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error, |
@@ 5629-5653 (lines=25) @@ | ||
5626 | return files_belong_to_same_module, common_path |
|
5627 | ||
5628 | ||
5629 | def UpdateIncludeState(filename, include_dict, io=codecs): |
|
5630 | """Fill up the include_dict with new includes found from the file. |
|
5631 | ||
5632 | Args: |
|
5633 | filename: the name of the header to read. |
|
5634 | include_dict: a dictionary in which the headers are inserted. |
|
5635 | io: The io factory to use to read the file. Provided for testability. |
|
5636 | ||
5637 | Returns: |
|
5638 | True if a header was successfully added. False otherwise. |
|
5639 | """ |
|
5640 | headerfile = None |
|
5641 | try: |
|
5642 | headerfile = io.open(filename, 'r', 'utf8', 'replace') |
|
5643 | except IOError: |
|
5644 | return False |
|
5645 | linenum = 0 |
|
5646 | for line in headerfile: |
|
5647 | linenum += 1 |
|
5648 | clean_line = CleanseComments(line) |
|
5649 | match = _RE_PATTERN_INCLUDE.search(clean_line) |
|
5650 | if match: |
|
5651 | include = match.group(2) |
|
5652 | include_dict.setdefault(include, linenum) |
|
5653 | return True |
|
5654 | ||
5655 | ||
5656 | def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error, |