Skip to content
Browse files
Fixing wrong .dep filename bug.
  • Loading branch information
felixfontein committed Oct 29, 2016
1 parent 3c5edb3 commit 83ffc8bad8098ca9671f12c729ec47442c19e296
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
@@ -263,9 +263,13 @@ class PageCompiler(BasePlugin):
config_dependencies = []

def _read_extra_deps(self, post):
def get_dep_filename(self, post, lang):
"""Return the .dep file's name for the given post and language."""
return post.translated_base_path(lang) + '.dep'

def _read_extra_deps(self, post, lang):
"""Read contents of .dep file and return them as a list."""
dep_path = post.base_path + '.dep'
dep_path = self.get_dep_filename(post, lang)
if os.path.isfile(dep_path):
with, 'r+', encoding='utf8') as depf:
deps = [l.strip() for l in depf.readlines()]
@@ -274,12 +278,16 @@ def _read_extra_deps(self, post):

def register_extra_dependencies(self, post):
"""Add dependency to post object to check .dep file."""
post.add_dependency(lambda: self._read_extra_deps(post), 'fragment')
def create_lambda(lang):
return lambda: self._read_extra_deps(post, lang)

for lang in['TRANSLATIONS']:
post.add_dependency(create_lambda(lang), 'fragment')

def get_extra_targets(self, post, lang, dest):
"""Return a list of extra targets for the render_posts task when compiling the post for the specified language."""
if self.use_dep_file:
return [post.base_path + '.dep']
return [self.get_dep_filename(post, lang)]
return []

@@ -461,9 +461,12 @@ def register_depfile(self, dep, dest=None, lang=None):

def write_depfile(dest, deps_list, post=None):
def write_depfile(dest, deps_list, post=None, lang=None):
"""Write a depfile for a given language."""
deps_path = dest + '.dep'
if post is None or lang is None:
deps_path = dest + '.dep'
deps_path = post.compiler.get_dep_filename(post, lang)
if deps_list or (post.compiler.use_dep_file if post else False):
deps_list = [p for p in deps_list if p != dest] # Don't depend on yourself (#1671)
with, "w+", encoding="utf8") as deps_file:
@@ -543,7 +546,7 @@ def wrap_encrypt(path, password):
Post.write_depfile(dest, self._depfile[dest], post=self)
Post.write_depfile(dest, self._depfile[dest], post=self, lang=lang)

'source': self.translated_source_path(lang),

0 comments on commit 83ffc8b

Please sign in to comment.