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

Unified Diff: watchlists.py

Issue 126272: Add unit tests for watchlists (Closed) Base URL: svn://chrome-svn/chrome/trunk/tools/depot_tools/
Patch Set: '' Created 11 years, 6 months 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 | « tests/watchlists_unittest.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: watchlists.py
===================================================================
--- watchlists.py (revision 18614)
+++ watchlists.py (working copy)
@@ -45,19 +45,30 @@
self._LoadWatchlistRules()
def _GetRulesFilePath(self):
+ """Returns path to WATCHLISTS file."""
return os.path.join(self._repo_root, self._RULES_FILENAME)
def _HasWatchlistsFile(self):
"""Determine if watchlists are available for this repo."""
return os.path.exists(self._GetRulesFilePath())
+ def _ContentsOfWatchlistsFile(self):
+ """Read the WATCHLISTS file and return its contents."""
+ try:
+ watchlists_file = open(self._GetRulesFilePath())
+ contents = watchlists_file.read()
+ watchlists_file.close()
+ return contents
+ except IOError, e:
+ logging.error("Cannot read %s: %s" % (self._GetRulesFilePath(), e))
+ return ''
+
def _LoadWatchlistRules(self):
+ """Load watchlists from WATCHLISTS file. Does nothing if not present."""
if not self._HasWatchlistsFile():
return
- watchlists_file = open(self._GetRulesFilePath())
- contents = watchlists_file.read()
- watchlists_file.close()
+ contents = self._ContentsOfWatchlistsFile()
watchlists_data = None
try:
watchlists_data = eval(contents, {'__builtins__': None}, None)
« no previous file with comments | « tests/watchlists_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698