Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Unified Diff: tools/deep_memory_profiler/lib/policy.py

Issue 698183002: Add 'path' member in policies.json to specify policy file path Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/deep_memory_profiler/lib/policy.py
diff --git a/tools/deep_memory_profiler/lib/policy.py b/tools/deep_memory_profiler/lib/policy.py
index 2a41bb25106740ffa1ca695a5b50ff81bea5163b..1de24d91a9f5e0dbd451b90cb194aff09c5a2090 100644
--- a/tools/deep_memory_profiler/lib/policy.py
+++ b/tools/deep_memory_profiler/lib/policy.py
@@ -253,7 +253,7 @@ class Policy(object):
assert False
@staticmethod
- def load(filename, filetype):
+ def load(path, filename, filetype):
"""Loads a policy file of |filename| in a |format|.
Args:
@@ -264,7 +264,11 @@ class Policy(object):
Returns:
A loaded Policy object.
"""
- with open(os.path.join(BASE_PATH, filename)) as policy_f:
+ if not path:
+ path = BASE_PATH
+ elif path[0] == '.':
+ path = os.path.join(BASE_PATH, path)
+ with open(os.path.join(path, filename)) as policy_f:
return Policy.parse(policy_f, filetype)
@staticmethod
@@ -402,7 +406,10 @@ class PolicySet(object):
policies = {}
for label in directory:
LOGGER.info(' %s: %s' % (label, directory[label]['file']))
- loaded = Policy.load(directory[label]['file'], directory[label]['format'])
+ path = None
+ if 'path' in directory[label]:
+ path = directory[label]['path']
+ loaded = Policy.load(path, directory[label]['file'], directory[label]['format'])
if loaded:
policies[label] = loaded
return PolicySet(policies)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698