def locate_resource_dirs(self, complement, pattern="*.*", recursive=True, apps=[]): dirs = [] for app in settings.INSTALLED_APPS: fromlist = "" if len(app.split(".")) > 1: fromlist = ".".join(app.split(".")[1:]) if app.startswith('django'): continue if apps and not app in apps: continue module = __import__(app, fromlist=fromlist) app_dir = abspath("/" + "/".join(module.__file__.split("/")[1:-1])) resource_dir = join(app_dir, complement) if exists(resource_dir) and locate(pattern, resource_dir, recursive): dirs.append(resource_dir) return dirs
def locate_resource_dirs(self, complement, pattern="*.*", recursive=True, apps=[]): dirs = [] for app in settings.INSTALLED_APPS: fromlist = "" if len(app.split("."))>1: fromlist = ".".join(app.split(".")[1:]) if app.startswith('django'): continue if apps and not app in apps: continue module = __import__(app, fromlist=fromlist) app_dir = abspath("/" + "/".join(module.__file__.split("/")[1:-1])) resource_dir = join(app_dir, complement) if exists(resource_dir) and locate(pattern, resource_dir, recursive): dirs.append(resource_dir) return dirs
def locate(self, path, pattern): return locate(root=path, pattern=pattern, recursive=False)
def list_files(self, directories, pattern): files = [] for directory in directories: files.extend(locate(root=directory, pattern=pattern)) return files