コード例 #1
0
ファイル: finders.py プロジェクト: 10clouds/edx-platform
 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
コード例 #2
0
    def test_baking(self):
        """Test that we can bake pages."""

        with tempfile.TemporaryDirectory() as outdir:
            storage = FileSystemStorage(location=outdir)
            bake(outdir)
            # We should have index.html, about/index.html, subdir/index.html
            EXPECTED_FILES = [
                'index.html',
                'about.html',
                'subdir/index.html',
            ]
            EXPECTED_SLUGS = [
                '',
                'about',
                'subdir/',
            ]
            self.assertEqual(
                set(EXPECTED_FILES),
                set(utils.get_files(storage)),
            )

            for fname, slug in zip(EXPECTED_FILES, EXPECTED_SLUGS):
                with open(
                    os.path.join(outdir, fname),
                    'rb',
                ) as fp:
                    self.assertEqual(
                        b'slug=' + slug.encode('utf-8'),
                        fp.read().strip(),
                    )
コード例 #3
0
    def _walk_assets_directory(self):
        ignore_filter = [self.config.assets_ignore
                         ] if self.config.assets_ignore else None

        def add_resource(p, filepath):
            res = {'asset_path': p, 'filepath': filepath}
            if self.config.assets_external_path:
                res['external_url'] = '{}{}'.format(
                    self.config.assets_external_path, path)
            return res

        files = list(
            get_files(staticfiles_storage,
                      ignore_patterns=ignore_filter,
                      location=self.config.assets_folder))
        for f in sorted(files):
            path = staticfiles_storage.url(f)
            full = staticfiles_storage.path(f)

            if f.endswith('js'):
                self.scripts.append_script(add_resource(path, full))
            elif f.endswith('css'):
                self.css.append_css(add_resource(path, full))
            elif f.endswith('favicon.ico'):
                self._favicon = path
コード例 #4
0
ファイル: finders.py プロジェクト: devs1991/test_edx_docmode
 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
コード例 #5
0
 def list(self, ignore_patterns):
     for component_name in self.locations:
         storage = self.storages[component_name]
         for path in get_files(storage,
                               ignore_patterns + self.ignore_patterns):
             print("DashAssetFinder", path, storage)
             yield path, storage
コード例 #6
0
ファイル: finders.py プロジェクト: osalas891123/ecommerce
 def list(self, ignore_patterns):
     """
     List all files in all theme storages.
     """
     for storage in six.itervalues(self.storages):
         if storage.exists(''):  # check if storage location exists
             for path in utils.get_files(storage, ignore_patterns):
                 yield path, storage
コード例 #7
0
 def list(self, ignore_patterns):
     """
     List all files in all locations.
     """
     for prefix, root in self.locations:
         storage = self.storages[root]
         for path in utils.get_files(storage, ignore_patterns):
             yield path, storage
コード例 #8
0
 def list(self, ignore_patterns):
     """
     List all files in all locations.
     """
     for prefix, root in self.locations:
         storage = self.storages[root]
         for path in utils.get_files(storage, ignore_patterns):
             yield path, storage
コード例 #9
0
def helppages_index(request):
    s = StaticFilesStorage()
    pages = list(get_files(s, location='helppages'))

    slugs = [x[10:-5] for x in pages]
    pks = [x[10:-1].split('_')[0] for x in pages]

    return render(request, 'article_index.html', locals())
コード例 #10
0
 def list(self, ignore_patterns):
     """
     List all static files in all xblock packages.
     """
     for storage in self.package_storages:
         if storage.exists(''):  # check if storage location exists
             for path in utils.get_files(storage, ignore_patterns):
                 yield path, storage
コード例 #11
0
ファイル: finder.py プロジェクト: Lektorium-LLC/edx-platform
 def list(self, ignore_patterns):
     """
     List all static files in all xblock packages.
     """
     for storage in self.package_storages:
         if storage.exists(''):  # check if storage location exists
             for path in utils.get_files(storage, ignore_patterns):
                 yield path, storage
コード例 #12
0
 def list(self, ignore_patterns):
     """
     List all files in all app storages.
     """
     for storage in six.itervalues(self.storages):
         if storage.exists(''):  # check if storage location exists
             for path in utils.get_files(storage, ignore_patterns):
                 yield path, storage
コード例 #13
0
ファイル: finders.py プロジェクト: Gautier/django-xstatic
 def list(self, ignore_patterns=[]):
     """
     List all files in xstatic.* packages in INSTALLED_APPS
     Untested
     """
     for app, storage in self.storages.items():
         for path in utils.get_files(storage, ignore_patterns):
             yield path, storage
コード例 #14
0
ファイル: finders.py プロジェクト: OpenServicesEU/LZK
 def list(self, ignore_patterns):
     for virtual, paths in self.entries.items():
         for path in paths:
             storage = ScopedFileSystemStorage(location=str(path),
                                               directory=str(virtual))
             files = utils.get_files(storage, ignore_patterns)
             for name in files:
                 yield str(virtual / name), storage
コード例 #15
0
ファイル: finders.py プロジェクト: ZekriSara/pfe
 def list(self, ignore_patterns):
     """
     List all files in all app storages.
     """
     for storage in self.storages.values():
         if storage.exists(""):  # check if storage location exists
             for path in utils.get_files(storage, ignore_patterns):
                 yield path, storage
コード例 #16
0
 def list(self, ignore_patterns):
     storyfiles_dir = settings.HOMESTUCK_STORYFILES_DIR
     dirs = glob(os.path.join(storyfiles_dir, "*", "img")) + \
            glob(os.path.join(storyfiles_dir, "*", "*", "img"))
     for directory in dirs:
         storage = FileSystemStorage(location=directory)
         storage.prefix = "storyfiles"
         for path in utils.get_files(storage, ignore_patterns):
            yield path, storage
コード例 #17
0
 def list(self, ignore_patterns):
     """
     List all files in all app storages.
     """
     for storage in self.storages.itervalues():
         if storage.exists(''):  # check if storage location exists
             prefix = storage.get_prefix()
             for path in utils.get_files(storage, ignore_patterns):
                 yield path, prefix, storage
コード例 #18
0
 def list(self, ignore_patterns):
     """ List static files in all locations.
     """
     for prefix, root in self.locations:  # pylint: disable=unused-variable
         storage = self.storages[root]
         for path in utils.get_files(storage,
                                     ignore_patterns=self.ignore_patterns +
                                     (ignore_patterns or [])):
             yield path, storage
コード例 #19
0
    def list(self, ignore_patterns):
        """Lists static files within all enabled extensions."""
        for extension_manager in get_extension_managers():
            for extension in extension_manager.get_enabled_extensions():
                storage = self._get_storage(extension)

                if storage and storage.exists(''):
                    for path in get_files(storage, ignore_patterns):
                        yield path, storage
コード例 #20
0
ファイル: staticfiles.py プロジェクト: svetlyak40wt/djblets
    def list(self, ignore_patterns):
        """Lists static files within all enabled extensions."""
        for extension_manager in get_extension_managers():
            for extension in extension_manager.get_enabled_extensions():
                storage = self._get_storage(extension)

                if storage and storage.exists(''):
                    for path in get_files(storage, ignore_patterns):
                        yield path, storage
コード例 #21
0
ファイル: finders.py プロジェクト: ZekriSara/pfe
 def list(self, ignore_patterns):
     """
     List all files in all locations.
     """
     for prefix, root in self.locations:
         # Skip nonexistent directories.
         if os.path.isdir(root):
             storage = self.storages[root]
             for path in utils.get_files(storage, ignore_patterns):
                 yield path, storage
コード例 #22
0
 def list(self, *args, **kwargs):
     try:
         with open(settings.NODE_PACKAGE_JSON) as f:
             package_json = json.load(f)
     except IOError:
         for path in get_files(self.storage, self.ignore_patterns):
             yield path, self.storage
     else:
         if 'dependencies' in package_json and isinstance(
                 package_json['dependencies'], dict):
             node_modules = {
                 node_module
                 for node_module in package_json['dependencies'].keys()
             }
             for module in node_modules:
                 if self.storage.exists(module):
                     for path in get_files(self.storage,
                                           self.ignore_patterns, module):
                         yield path, self.storage
コード例 #23
0
    def list(self, ignore_patterns, all_storages=False):
        if all_storages:
            locations = self.locations
        else:
            locations = [('', self.extension_static_dir)]

        for prefix, root in locations:
            storage = self.storages[root]

            for path in get_files(storage, ignore_patterns):
                yield path, storage
コード例 #24
0
ファイル: staticfiles.py プロジェクト: svetlyak40wt/djblets
    def list(self, ignore_patterns, all_storages=False):
        if all_storages:
            locations = self.locations
        else:
            locations = [('', self.extension_static_dir)]

        for prefix, root in locations:
            storage = self.storages[root]

            for path in get_files(storage, ignore_patterns):
                yield path, storage
コード例 #25
0
    def list(self, ignore_patterns, layer=None):
        """
        List all files in all app storages.
        """
        if not layer:
            return

        for storage in self.storages.itervalues():
            layer_storage = storage.get(layer, None)
            if layer_storage and layer_storage.exists(''):
                for path in utils.get_files(layer_storage, ignore_patterns):
                    yield path, layer_storage
コード例 #26
0
ファイル: finders.py プロジェクト: iivvoo/django_layers
    def list(self, ignore_patterns, layer=None):
        """
        List all files in all app storages.
        """
        if not layer:
            return

        for storage in self.storages.itervalues():
            layer_storage = storage.get(layer, None)
            if layer_storage and layer_storage.exists(''):
                for path in utils.get_files(layer_storage, ignore_patterns):
                    yield path, layer_storage
コード例 #27
0
 def get_files(self, ignore_patterns=[]):
     """
     Return a list containing the relative source paths for all files that
     should be copied for an app.
     """
     files = []
     prefix = self.get_prefix()
     for path in utils.get_files(self, ignore_patterns):
         if prefix:
             path = '/'.join([prefix, path])
         files.append(path)
     return files
コード例 #28
0
ファイル: storage.py プロジェクト: RefuX/applause
 def get_files(self, ignore_patterns=[]):
     """
     Return a list containing the relative source paths for all files that
     should be copied for an app.
     """
     files = []
     prefix = self.get_prefix()
     for path in utils.get_files(self, ignore_patterns):
         if prefix:
             path = '/'.join([prefix, path])
         files.append(path)
     return files
コード例 #29
0
 def list(self, ignore_patterns):
     """ List static files in all locations.
     """
     for prefix, root in self.locations:  # pylint: disable=unused-variable
         storage = self.storages[root]
         temp_storage = FileSystemStorage(location=storage.location)
         version = import_module(root.split('/')[-1]).__version__
         for path in utils.get_files(storage, ignore_patterns=self.ignore_patterns + (ignore_patterns or [])):
             modified = int(os.stat(temp_storage.path(path)).st_mtime)
             new_path = build_fingerprint(path, version, modified)
             new_file_name, ext = new_path.rsplit('.', 1)
             with temp_storage.open(path) as source_file:
                 temp_storage.save(f'{new_file_name}_.{ext}', source_file)
             yield new_path, storage
コード例 #30
0
    def handle(self, *args, **options):
        local_storage = StaticFilesStorage()
        base_path = local_storage.base_location

        # Ignore files in our ignore patterns
        ignore_patterns = getattr(settings, 'SYNCSTATIC_IGNORE_PATTERNS', None)
        files = set(utils.get_files(local_storage, ignore_patterns=ignore_patterns))

        # Remove any files that went into compilation
        files -= set(settings.PIPELINE_JS['main']['source_filenames'])
        files -= set(settings.PIPELINE_CSS['main']['source_filenames'])

        for file in files:
            print('syncing to s3: %s' % file)
            staticfiles_storage.save(file, local_storage.open(file, 'r'))
コード例 #31
0
def list_files_in_app(app_names, source_dir, ignore_patterns):
    apps = []
    storages = SortedDict()

    for app in app_names:
       app_storage = CustomAppStaticStorage(source_dir, app)
       if os.path.isdir(app_storage.location):
           storages[app] = app_storage
           if app not in apps:
               apps.append(app)

    for storage in storages.itervalues():
        if storage.exists(''):  # check if storage location exists
            for path in utils.get_files(storage, ignore_patterns):
                yield path, storage
コード例 #32
0
    def handle(self, *args, **options):
        local_storage = StaticFilesStorage()
        base_path = local_storage.base_location

        # Ignore files in our ignore patterns
        ignore_patterns = getattr(settings, 'SYNCSTATIC_IGNORE_PATTERNS', None)
        files = set(
            utils.get_files(local_storage, ignore_patterns=ignore_patterns))

        # Remove any files that went into compilation
        files -= set(settings.PIPELINE_JS['main']['source_filenames'])
        files -= set(settings.PIPELINE_CSS['main']['source_filenames'])

        for file in files:
            print('syncing to s3: %s' % file)
            staticfiles_storage.save(file, local_storage.open(file, 'r'))
コード例 #33
0
 def _prefetch(self):
     if self._fetched is None:
         self._fetched = []
         #print("Starting _prefetch")
         for fname in utils.get_files(self._storage):
             #print("Found %s." % fname)
             _file = self.model(
                 self._storage,
                 self.metadata,
                 fname,
                 self.slug_suffices,
                 self.slug_strip_index,
             )
             if self._check_filters(_file):
                 #print("  matches filters")
                 self._fetched.append(_file)
コード例 #34
0
    def get_file_list(self, **kwargs):
        from staticpreprocessor.conf import settings

        file_list = get_files(self.storage, location=settings.STATIC_PREPROCESSOR_ROOT)
        if self.extensions is not None:
            file_list = filter(lambda f: os.path.splitext(f)[1] in self.extensions, file_list)
        if self.exclude_match:
            file_list = filter(lambda f: not fnmatch.fnmatch(f, self.exclude_match), file_list)
        if self.exclude_regex:
            exclude_regex = re.compile(self.exclude_regex)
            file_list = filter(lambda f: not bool(exclude_regex.search(f)), file_list)
        if self.include_match:
            file_list = filter(lambda f: fnmatch.fnmatch(f, self.include_match), file_list)
        if self.include_regex:
            include_regex = re.compile(self.include_regex)
            file_list = filter(lambda f: bool(include_regex.search(f)), file_list)
        return file_list
コード例 #35
0
ファイル: forms.py プロジェクト: alliocha1805/DCThemis
class CvTemplateForm(forms.Form):
    s = StaticFilesStorage()
    repertoire = []
    repertoire_pas_propre = list(get_files(s, location='collab'))
    for elt in repertoire_pas_propre:
        if "assets" in elt:
            pass
        else:
            nomDoc = elt.replace("collab\\", '')
            if ".docx" in nomDoc:
                valeur = (nomDoc, nomDoc)
                repertoire.append(valeur)
            else:
                pass
    template = forms.CharField(label='Quel template voulez-vous ?',
                               widget=forms.Select(choices=repertoire))
    collabid = forms.CharField(widget=forms.HiddenInput(), required=True)
コード例 #36
0
ファイル: dash.py プロジェクト: pikhovkin/dj-plotly-dash
    def _walk_assets_directory(self):
        ignore_patterns = [self.config.assets_ignore
                           ] if self.config.assets_ignore else None
        files = list(
            get_files(staticfiles_storage,
                      ignore_patterns=ignore_patterns,
                      location=self.config.assets_folder))
        for f in sorted(files):
            path = staticfiles_storage.url(f)
            full = staticfiles_storage.path(f)

            if f.endswith('js'):
                self.scripts.append_script(
                    self._add_assets_resource(path, full))
            elif f.endswith('css'):
                self.css.append_css(self._add_assets_resource(path, full))
            elif f.endswith('favicon.ico'):
                self._favicon = path
コード例 #37
0
ファイル: finders.py プロジェクト: knivets/djaodjin-multitier
 def list(self, ignore_patterns):
     """
     List all files in all locations.
     """
     locations, storages = self.get_locations()
     for _, root in locations:
         storage = storages[root]
         try:
             for path in utils.get_files(storage, ignore_patterns):
                 yield path, storage
         except OSError as err:
             if err.errno == errno.ENOENT:
                 # suppress "No such file or directory" error because
                 # non-existent directories are considered optional search
                 # path here.
                 pass
             else:
                 raise
コード例 #38
0
 def list(self, ignore_patterns):
     """
     List all files in all locations.
     """
     locations, storages = self.get_locations()
     for _, root in locations:
         storage = storages[root]
         try:
             for path in utils.get_files(storage, ignore_patterns):
                 yield path, storage
         except OSError as err:
             if err.errno == errno.ENOENT:
                 # suppress "No such file or directory" error because
                 # non-existent directories are considered optional search
                 # path here.
                 pass
             else:
                 raise
コード例 #39
0
    def test_baking(self):
        """Test that we can bake pages."""

        with tempfile.TemporaryDirectory() as outdir:
            storage = FileSystemStorage(location=outdir)
            bake(outdir)
            # We should have various.
            EXPECTED_FILES = {
                'blog/index.html',
                'blog/p2/index.html',
                'blog/2016/index.html',
                'blog/2016/p2/index.html',
                'blog/2016/05/index.html',
                'blog/2016/06/index.html',
                'blog/2016/07/index.html',
                'blog/2016/05/21/index.html',
                'blog/2016/06/21/index.html',
                'blog/2016/07/21/index.html',
                'blog/2016/05/21/single-post.html',
                'blog/2016/06/21/single-post.html',
                'blog/2016/07/21/single-post.html',
                'blog/2016/05/21/second-post.html',
                'blog/2016/06/21/second-post.html',
                'blog/2016/07/21/second-post.html',
                'blog/2016/05/21/third-post.html',
                'blog/2016/06/21/third-post.html',
                'blog/2016/07/21/third-post.html',
                'blog/2016/05/21/fourth-post.html',
                'blog/2016/06/21/fourth-post.html',
                'blog/2016/07/21/fourth-post.html',
                'blog/2016/05/21/fifth-post.html',
                'blog/2016/06/21/fifth-post.html',
                'blog/2016/07/21/fifth-post.html',
                'blog/index.atom',
                'blog/drafts/draft-post.html',
                'blog/drafts/second-draft-post.html',
            }
            self.assertEqual(
                EXPECTED_FILES,
                set(utils.get_files(storage)),
            )
コード例 #40
0
 def get_file_list(self, **kwargs):
     from staticpreprocessor.conf import settings
     file_list = get_files(self.storage,
                           location=settings.STATIC_PREPROCESSOR_ROOT)
     if self.extensions is not None:
         file_list = filter(
             lambda f: os.path.splitext(f)[1] in self.extensions, file_list)
     if self.exclude_match:
         file_list = filter(
             lambda f: not fnmatch.fnmatch(f, self.exclude_match),
             file_list)
     if self.exclude_regex:
         exclude_regex = re.compile(self.exclude_regex)
         file_list = filter(lambda f: not bool(exclude_regex.search(f)),
                            file_list)
     if self.include_match:
         file_list = filter(
             lambda f: fnmatch.fnmatch(f, self.include_match), file_list)
     if self.include_regex:
         include_regex = re.compile(self.include_regex)
         file_list = filter(lambda f: bool(include_regex.search(f)),
                            file_list)
     return file_list
コード例 #41
0
ファイル: staticfiles.py プロジェクト: xuzhuwukong/djblets
    def list(self, ignore_patterns, all_storages=False):
        if all_storages:
            locations = self.locations
        else:
            locations = [('', self.extension_static_dir)]

        for prefix, root in locations:
            try:
                storage = self.storages[root]
            except KeyError:
                # If this is hit, look for any calls to static() that are
                # part of a class definition somewhere in the consuming
                # application. These need to be dealt with.
                raise KeyError('Unable to find a static files storage class '
                               'for "%s". This is most likely due to a '
                               'bug in the consuming application where '
                               'static() is called too early, or where '
                               'djblets.urls.staticfiles.static_lazy() should '
                               'be used instead.'
                               % root)

            for path in get_files(storage, ignore_patterns):
                yield path, storage
コード例 #42
0
def find_static_files():
    storage = StaticFilesStorage()
    static_url = getattr(settings, 'STATIC_URL')
    return ['{}{}'.format(static_url, file) for file in get_files(storage)]
コード例 #43
0
ファイル: themes.py プロジェクト: Fiware/apps.Wirecloud
 def _list(self, storages, ignore_patterns=[]):
     for storage in storages:
         if storage.exists("."):
             for path in utils.get_files(storage, ignore_patterns):
                 yield path, storage
コード例 #44
0
ファイル: render.py プロジェクト: AgentK1729/insights
 def list(self, ignore_patterns):
     for module, path, storage in self.static_paths:
         for path in utils.get_files(storage, ignore_patterns):
             yield path, storage
コード例 #45
0
ファイル: utils copy.py プロジェクト: reza-sajadee/mobinsb
def get_file():
    s = StaticFilesStorage()
    return list(get_files(s, location='adj'))
コード例 #46
0
 def list(self, ignore_patterns):
     """
     List all files of the storage.
     """
     for path in utils.get_files(self.storage, ignore_patterns):
         yield path, '', self.storage
コード例 #47
0
import os
コード例 #48
0
 def list(self, ignore_patterns):
     storage = self._storage
     for path in get_files(storage, ignore_patterns):
         yield path, storage
コード例 #49
0
 def list(self, ignore_patterns):
     for path in utils.get_files(self.manifest_storage, ignore_patterns):
         yield path, self.manifest_storage
コード例 #50
0
 def list(self, ignore_patterns):
     storage = self._get_storage()
     for path in utils.get_files(storage, ignore_patterns):
         yield path, storage
コード例 #51
0
ファイル: vstorage.py プロジェクト: Aalto-LeTech/mooc-jutut
 def list(self, ignore_patterns):
     storage = self._storage
     for path in get_files(storage, ignore_patterns):
         yield path, storage
コード例 #52
0
 def process_require_tree(self, asset, path):
     path = self.resolve(asset, path)
     asset.depend_on(asset.storage.path(path))
     for filename in get_files(asset.storage, location=path):
         asset.require_asset(filename)
コード例 #53
0
 def list(self, ignore_patterns):
     for component_name in self.locations:
         storage = self.storages[component_name]
         for path in get_files(storage, ignore_patterns + self.ignore_patterns):
             yield path, storage
コード例 #54
0
 def list(self, *args, **kwargs):
     for path in get_files(self.storage, self.ignore_patterns):
         yield path, self.storage
コード例 #55
0
ファイル: themes.py プロジェクト: Yaco-Sistemas/wirecloud
 def list(self, ignore_patterns=[]):
     for location in (self.active_theme_location,
                      self.default_theme_location):
         storage = FileSystemStorage(location=location)
         for path in utils.get_files(storage, ignore_patterns):
             yield path, storage
コード例 #56
0
 def list(self, ignore_patterns):
     if os.path.exists(self.storage.location):
         for path in utils.get_files(self.storage, ignore_patterns):
             yield path, self.storage