Browse Source

Added code to update the dependencies on change

main
Lakshmi Vyasarajan 14 years ago
parent
commit
a78548510b
1 changed files with 23 additions and 14 deletions
  1. +23
    -14
      hyde/generator.py

+ 23
- 14
hyde/generator.py View File

@@ -114,22 +114,30 @@ class Generator(object):
""" """
Gets the dependencies for a given resource. Gets the dependencies for a given resource.
""" """

rel_path = resource.relative_path
deps = self.deps[rel_path] if rel_path in self.deps \
else self.update_deps(resource)
return deps

def update_deps(self, resource):
"""
Updates the dependencies for the given resource.
"""

rel_path = resource.relative_path rel_path = resource.relative_path
deps = [] deps = []
if not rel_path in self.deps:
if hasattr(resource, 'depends'):
user_deps = resource.depends
for dep in user_deps:
deps.append(dep)
deps.extend(self.template.get_dependencies(dep))

deps.extend(self.template.get_dependencies(resource.relative_path))
deps = list(set(deps))
if None in deps:
deps.remove(None)
self.deps[rel_path] = deps
else:
deps = self.deps[rel_path]
if hasattr(resource, 'depends'):
user_deps = resource.depends
for dep in user_deps:
deps.append(dep)
deps.extend(self.template.get_dependencies(dep))

deps.extend(self.template.get_dependencies(resource.relative_path))
deps = list(set(deps))
if None in deps:
deps.remove(None)
self.deps[rel_path] = deps
return deps return deps


def has_resource_changed(self, resource): def has_resource_changed(self, resource):
@@ -281,6 +289,7 @@ class Generator(object):
logger.debug("No changes found. Skipping resource [%s]", resource) logger.debug("No changes found. Skipping resource [%s]", resource)
return return
logger.debug("Processing [%s]", resource) logger.debug("Processing [%s]", resource)
self.update_deps(resource)
with self.context_for_resource(resource) as context: with self.context_for_resource(resource) as context:
if resource.source_file.is_text: if resource.source_file.is_text:
if resource.uses_template: if resource.uses_template:


Loading…
Cancel
Save