Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: cms/sources.py

Issue 5488197752586240: Issue 2440 - implement Source.get_cache_dir() to be used by custom filters/globals (Closed)
Patch Set: Got rid of redundant CMS_CACHE_DIR variable Created April 30, 2015, 2:36 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
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: cms/sources.py
===================================================================
--- a/cms/sources.py
+++ b/cms/sources.py
@@ -211,6 +211,8 @@
command = ["hg", "-R", repo, "id", "-n", "-r", "default"]
self.version = subprocess.check_output(command).strip()
+ self._origin = urlparse.urlsplit(repo).path.strip('/')
Wladimir Palant 2015/04/30 15:45:09 |hg archive| won't work for remote repositories, s
Sebastian Noack 2015/04/30 18:09:19 Fixed. Note that urlparse.urlsplit() did actually
+
def __enter__(self):
return self
@@ -240,6 +242,10 @@
if filename.startswith(prefix):
yield filename[len(prefix):]
+ if os.name == "posix":
+ def get_cache_dir(self):
+ return "/var/cache/" + self._origin
+
class FileSource(Source):
def __init__(self, dir):
self._dir = dir
@@ -280,3 +286,6 @@
do_list(path, relpath + filename + "/")
do_list(self.get_path(subdir), "")
return result
+
+ def get_cache_dir(self):
+ return os.path.join(self._dir, "cache")
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld