class ComprehensiveThemeFinder(BaseFinder): """ A static files finder that searches the active comprehensive theme for static files. If the ``COMPREHENSIVE_THEME_DIR`` setting is unset, or the ``COMPREHENSIVE_THEME_DIR`` does not exist on the file system, this finder will never find any files. """ def __init__(self, *args, **kwargs): super(ComprehensiveThemeFinder, self).__init__(*args, **kwargs) theme_dir = getattr(settings, "COMPREHENSIVE_THEME_DIR", "") if not theme_dir: self.storage = None return if not isinstance(theme_dir, basestring): raise ImproperlyConfigured( "Your COMPREHENSIVE_THEME_DIR setting must be a string") root = Path(settings.PROJECT_ROOT) if root.name == "": root = root.parent component_dir = Path(theme_dir) / root.name static_dir = component_dir / "static" self.storage = CachedComprehensiveThemingStorage(location=static_dir) def find(self, path, all=False): # pylint: disable=redefined-builtin """ Looks for files in the default file storage, if it's local. """ if not self.storage: return [] if path.startswith(self.storage.prefix): # strip the prefix path = path[len(self.storage.prefix):] if self.storage.exists(path): match = self.storage.path(path) if all: match = [match] return match return [] def list(self, ignore_patterns): """ List all files of the storage. """ if self.storage and self.storage.exists(''): for path in utils.get_files(self.storage, ignore_patterns): yield path, self.storage
class ComprehensiveThemeFinder(BaseFinder): """ A static files finder that searches the active comprehensive theme for static files. If the ``COMPREHENSIVE_THEME_DIR`` setting is unset, or the ``COMPREHENSIVE_THEME_DIR`` does not exist on the file system, this finder will never find any files. """ def __init__(self, *args, **kwargs): super(ComprehensiveThemeFinder, self).__init__(*args, **kwargs) theme_dir = getattr(settings, "COMPREHENSIVE_THEME_DIR", "") if not theme_dir: self.storage = None return if not isinstance(theme_dir, basestring): raise ImproperlyConfigured("Your COMPREHENSIVE_THEME_DIR setting must be a string") root = Path(settings.PROJECT_ROOT) if root.name == "": root = root.parent component_dir = Path(theme_dir) / root.name static_dir = component_dir / "static" self.storage = CachedComprehensiveThemingStorage(location=static_dir) def find(self, path, all=False): # pylint: disable=redefined-builtin """ Looks for files in the default file storage, if it's local. """ if not self.storage: return [] if path.startswith(self.storage.prefix): # strip the prefix path = path[len(self.storage.prefix):] if self.storage.exists(path): match = self.storage.path(path) if all: match = [match] return match return [] def list(self, ignore_patterns): """ List all files of the storage. """ if self.storage and self.storage.exists(''): for path in utils.get_files(self.storage, ignore_patterns): yield path, self.storage
def __init__(self, *args, **kwargs): super(ComprehensiveThemeFinder, self).__init__(*args, **kwargs) theme_dir = getattr(settings, "COMPREHENSIVE_THEME_DIR", "") if not theme_dir: self.storage = None return if not isinstance(theme_dir, basestring): raise ImproperlyConfigured( "Your COMPREHENSIVE_THEME_DIR setting must be a string") root = Path(settings.PROJECT_ROOT) if root.name == "": root = root.parent component_dir = Path(theme_dir) / root.name static_dir = component_dir / "static" self.storage = CachedComprehensiveThemingStorage(location=static_dir)
def __init__(self, *args, **kwargs): super(ComprehensiveThemeFinder, self).__init__(*args, **kwargs) theme_dir = getattr(settings, "COMPREHENSIVE_THEME_DIR", "") if not theme_dir: self.storage = None return if not isinstance(theme_dir, basestring): raise ImproperlyConfigured("Your COMPREHENSIVE_THEME_DIR setting must be a string") root = Path(settings.PROJECT_ROOT) if root.name == "": root = root.parent component_dir = Path(theme_dir) / root.name static_dir = component_dir / "static" self.storage = CachedComprehensiveThemingStorage(location=static_dir)