def __call__(self, files): env = get_jinja_env(self.config, self.source)[0] for fname in files: self.dependencies.recompute_file(fname) total_changed = set() for fname in files: total_changed.add(fname) total_changed.update(self.dependencies.get_affected_files(fname)) for fname in total_changed: fullsource = os.path.join(self.source, fname) fulldest = os.path.join(self.dest, fname) if fname.lower().endswith('.html'): compile_file(env, fname, fullsource, fulldest, False) elif staticlib.handle_precompile_file(fullsource, fulldest): continue else: copy_file(fullsource, fulldest, False)
def walk_and_compile(env, source, dest, incremental, save, changed): for dirpath, dirnames, filenames in os.walk(source, followlinks=True): reldir = dirpath[len(source):].lstrip('/') for filename in filenames: fullsource = os.path.join(source, reldir, filename) fulldest = os.path.join(dest, reldir, filename) if not filename.lower().endswith('.html'): if save and not staticlib.handle_precompile_file(fullsource, fulldest, incremental=incremental): copy_file(fullsource, fulldest, incremental) continue if save: target_file = os.path.join(dest, reldir, filename) else: target_file = None try: if not incremental or os.path.join(reldir, filename) in changed: compile_file(env, os.path.join(reldir, filename), os.path.join(dirpath, filename), target_file, False) except Exception as e: logger.error(" In file {0}: {1}".format(os.path.join(reldir, filename), str(e)), exc_info=True)