diff options
author | Nick Mathewson <nickm@torproject.org> | 2019-08-05 17:31:49 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-08-05 17:48:06 -0400 |
commit | 2a3c727dfed7465090c2b9bae2f5ac88b3c6dca0 (patch) | |
tree | 36dd005938c308a670f8a72b3247ba07145f0f2c /scripts/maint/practracker/includes.py | |
parent | 6b26281b50f25f0175f3ba801951324a30ba7a32 (diff) | |
download | tor-2a3c727dfed7465090c2b9bae2f5ac88b3c6dca0.tar.gz tor-2a3c727dfed7465090c2b9bae2f5ac88b3c6dca0.zip |
Make includes interface more like the rest of practracker
Everything else assumes that somebody else will open the file for it.
Diffstat (limited to 'scripts/maint/practracker/includes.py')
-rwxr-xr-x | scripts/maint/practracker/includes.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/scripts/maint/practracker/includes.py b/scripts/maint/practracker/includes.py index fbd68f4f52..fcc527c983 100755 --- a/scripts/maint/practracker/includes.py +++ b/scripts/maint/practracker/includes.py @@ -103,11 +103,9 @@ class Rules(object): "Forbidden include of {}".format(include), is_advisory=self.is_advisory) - def applyToFile(self, fname): - with open_file(fname) as f: - #print(fname) - for error in self.applyToLines(iter(f), "{}:".format(fname)): - yield error + def applyToFile(self, fname, f): + for error in self.applyToLines(iter(f), "{}:".format(fname)): + yield error def noteUnusedRules(self): for p in self.patterns: @@ -200,14 +198,14 @@ def toposort(graph, limit=100): return all_levels -def consider_include_rules(fname): +def consider_include_rules(fname, f): dirpath = os.path.split(fname)[0] rules_fname = os.path.join(dirpath, RULES_FNAME) rules = load_include_rules(os.path.join(dirpath, RULES_FNAME)) if rules is None: return - for err in rules.applyToFile(fname): + for err in rules.applyToFile(fname, f): yield err list_unused = False @@ -221,8 +219,9 @@ def walk_c_files(topdir="src"): for fname in fnames: if fname_is_c(fname): fullpath = os.path.join(dirpath,fname) - for err in consider_include_rules(fullpath): - yield err + with open(fullpath) as f: + for err in consider_include_rules(fullpath, f): + yield err def run_check_includes(topdir, list_unused=False, log_sorted_levels=False, list_advisories=False): |