mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-24 06:48:05 +01:00
checkIncludes: introduce rules-file caching.
We'll want this so that we can have each file evaluated independently, rather than a directory at a time.
This commit is contained in:
parent
475749351d
commit
3f35ac772b
1 changed files with 5 additions and 0 deletions
|
@ -123,8 +123,12 @@ class Rules(object):
|
|||
|
||||
return allowed
|
||||
|
||||
include_rules_cache = {}
|
||||
|
||||
def load_include_rules(fname):
|
||||
""" Read a rules file from 'fname', and return it as a Rules object. """
|
||||
if fname in include_rules_cache:
|
||||
return include_rules_cache[fname]
|
||||
result = Rules(os.path.split(fname)[0])
|
||||
with open_file(fname) as f:
|
||||
for line in f:
|
||||
|
@ -132,6 +136,7 @@ def load_include_rules(fname):
|
|||
if line.startswith("#") or not line:
|
||||
continue
|
||||
result.addPattern(line)
|
||||
include_rules_cache[fname] = result
|
||||
return result
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Add table
Reference in a new issue