Пример #1
0
    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
Пример #2
0
    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
Пример #3
0
 def locate(self, path, pattern):
     return locate(root=path, pattern=pattern, recursive=False)
Пример #4
0
 def list_files(self, directories, pattern):
     files = []
     for directory in directories:
         files.extend(locate(root=directory, pattern=pattern))
     return files
Пример #5
0
 def locate(self, path, pattern):
     return locate(root=path, pattern=pattern, recursive=False)
Пример #6
0
 def list_files(self, directories, pattern):
     files = []
     for directory in directories:
         files.extend(locate(root=directory, pattern=pattern))
     return files