def __init__(self): """Populate cache with source files.""" self._cache = [] proc_queue = [ (source.AssetSource, pathes.theme_assets()), (source.AssetSource, pathes.assets()), (source.PageSource, pathes.pages()), (source.PostSource, pathes.posts()), ] self._errors = [] for src_type, dir_path in proc_queue: def add_source(root, rel): try: file_name = os.path.join(root, rel) self._cache.append(src_type(file_name, root)) except Exception as e: self._errors.append((rel, e)) helpers.walk(dir_path, add_source)
def asset_exists(file_name): """Returns True if specified asset exists.""" asset_exists = os.path.isfile(pathes.assets(file_name)) return asset_exists or os.path.isfile(pathes.theme_assets(file_name))