Beispiel #1
0
 def has_resource_changed(self, resource):
     """
     Checks if the given resource has changed since the
     last generation.
     """
     logger.debug("Checking for changes in %s" % resource)
     self.load_site_if_needed()
     self.load_template_if_needed()
     target = File(self.site.config.deploy_root_path.child(
                             resource.relative_deploy_path))
     if not target.exists or target.older_than(resource.source_file):
         logger.debug("Found changes in %s" % resource)
         return True
     if resource.source_file.is_binary:
         logger.debug("No Changes found in %s" % resource)
         return False
     deps = self.get_dependencies(resource)
     if not deps or None in deps:
         logger.debug("No changes found in %s" % resource)
         return False
     content = self.site.content.source_folder
     layout = Folder(self.site.sitepath).child_folder('layout')
     logger.debug("Checking for changes in dependents:%s" % deps)
     for dep in deps:
         if not dep:
             return True
         source = File(content.child(dep))
         if not source.exists:
             source = File(layout.child(dep))
         if not source.exists:
             return True
         if target.older_than(source):
             return True
     logger.debug("No changes found in %s" % resource)
     return False
Beispiel #2
0
def test_time_functions():
    f1 = File(__file__)
    t1 = f1.last_modified
    f2 = File.make_temp("I am new")
    t2  = f2.last_modified
    assert t1 < t2
    assert f2.has_changed_since(t1)
    assert f1.older_than(f2)
Beispiel #3
0
def test_time_functions():
    f1 = File(__file__)
    t1 = f1.last_modified
    f2 = File.make_temp("I am new")
    t2 = f2.last_modified
    assert t1 < t2
    assert f2.has_changed_since(t1)
    assert f1.older_than(f2)