Exemplo n.º 1
0
 def create_packages(self, config):
     packages = {}
     if not config:
         return packages
     for name in config:
         packages[name] = {}
         if 'external_urls' in config[name]:
             packages[name]['externals'] = config[name]['external_urls']
             continue
         paths = []
         for pattern in config[name]['source_filenames']:
             for path in glob(pattern):
                 if not path in paths:
                     paths.append(str(path))
         packages[name]['paths'] = [path for path in paths if not path.endswith(settings.PIPELINE_TEMPLATE_EXT)]
         packages[name]['templates'] = [path for path in paths if path.endswith(settings.PIPELINE_TEMPLATE_EXT)]
         packages[name]['output'] = config[name]['output_filename']
         packages[name]['context'] = {}
         packages[name]['manifest'] = True
         if 'absolute_asset_paths' in config[name]:
             packages[name]['absolute_asset_paths'] = \
                 config[name]['absolute_asset_paths']
         if 'extra_context' in config[name]:
             packages[name]['context'] = config[name]['extra_context']
         if 'template_name' in config[name]:
             packages[name]['template'] = config[name]['template_name']
         if 'variant' in config[name]:
             packages[name]['variant'] = config[name]['variant']
         if 'manifest' in config[name]:
             packages[name]['manifest'] = config[name]['manifest']
     return packages
Exemplo n.º 2
0
 def create_packages(self, config):
     packages = {}
     if not config:
         return packages
     for name in config:
         packages[name] = {}
         if 'external_urls' in config[name]:
             packages[name]['externals'] = config[name]['external_urls']
             continue
         paths = []
         for pattern in config[name]['source_filenames']:
             for path in glob(pattern):
                 if path not in paths:
                     paths.append(str(path))
         packages[name]['paths'] = [
             path for path in paths if not path.endswith(
                 settings.PIPELINE_TEMPLATE_EXT)]
         packages[name]['templates'] = [
             path for path in paths if path.endswith(
                 settings.PIPELINE_TEMPLATE_EXT)]
         packages[name]['output'] = config[name]['output_filename']
         packages[name]['context'] = {}
         packages[name]['manifest'] = True
         if 'absolute_asset_paths' in config[name]:
             packages[name]['absolute_asset_paths'] = \
                 config[name]['absolute_asset_paths']
         if 'extra_context' in config[name]:
             packages[name]['context'] = config[name]['extra_context']
         if 'template_name' in config[name]:
             packages[name]['template'] = config[name]['template_name']
         if 'variant' in config[name]:
             packages[name]['variant'] = config[name]['variant']
         if 'manifest' in config[name]:
             packages[name]['manifest'] = config[name]['manifest']
     return packages
Exemplo n.º 3
0
 def sources(self):
     if not self._sources:
         paths = []
         for pattern in self.config.get('source_filenames', []):
             for path in glob(pattern):
                 if not path in paths:
                     paths.append(str(path))
         self._sources = paths
     return self._sources
Exemplo n.º 4
0
 def sources(self):
     if not self._sources:
         paths = []
         for pattern in self.config.get('source_filenames', []):
             for path in glob(pattern):
                 if not path in paths and find(path):
                     paths.append(str(path))
         self._sources = paths
     return self._sources
Exemplo n.º 5
0
    def sources(self):
        if not self._sources:
            paths = []
            for pattern in self.config.get('source_filenames', []):
                if path_is_url(pattern):
                    paths.append(pattern)
                    continue

                for path in glob(pattern):
                    if not path in paths:
                        paths.append(str(path))

            self._sources = paths
        return self._sources
Exemplo n.º 6
0
 def test_glob_directory_with_trailing_slash(self):
     # We are verifying that when there is wildcard pattern which
     # ends with os.sep doesn't blow up.
     paths = glob.glob('*' + os.sep)
     self.assertEqual(len(paths), 4)
     self.assertTrue(all([os.sep in path for path in paths]))
Exemplo n.º 7
0
 def glob(self, *parts):
     if len(parts) == 1:
         pattern = parts[0]
     else:
         pattern = os.path.join(*parts)
     return glob.glob(pattern)
Exemplo n.º 8
0
 def test_glob_directory_with_trailing_slash(self):
     # We are verifying that when there is wildcard pattern which
     # ends with os.sep doesn't blow up.
     paths = glob.glob('*' + os.sep)
     self.assertEqual(len(paths), 4)
     self.assertTrue(all([os.sep in path for path in paths]))
Exemplo n.º 9
0
 def glob(self, *parts):
     if len(parts) == 1:
         pattern = parts[0]
     else:
         pattern = os.path.join(*parts)
     return glob.glob(pattern)