Esempio n. 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
Esempio n. 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
Esempio n. 3
0
 def locate(self, path, pattern):
     return locate(root=path, pattern=pattern, recursive=False)
Esempio n. 4
0
 def list_files(self, directories, pattern):
     files = []
     for directory in directories:
         files.extend(locate(root=directory, pattern=pattern))
     return files
Esempio n. 5
0
 def locate(self, path, pattern):
     return locate(root=path, pattern=pattern, recursive=False)
Esempio n. 6
0
 def list_files(self, directories, pattern):
     files = []
     for directory in directories:
         files.extend(locate(root=directory, pattern=pattern))
     return files