Esempio n. 1
0
 def collect_references(self, references, output_base_path, relative_base_path):
     for reference in utils.inplace_gen(references):
         path = reference.get('path', 'NONE')
         file_import_path = os.path.join(self.component_directory, path)
         is_local = not ('http://' in file_import_path or 'https://' in file_import_path)
         if os.path.exists(file_import_path) and is_local:
             # Create dir and copy file
             file_output_path = os.path.join(output_base_path, path)
             utils.create_dir(os.path.dirname(file_output_path))
             shutil.copy(file_import_path, file_output_path)
             # Rename path
             file_relative_path = os.path.join(relative_base_path, path)
             reference['path'] = file_relative_path
Esempio n. 2
0
 def export_references(self, references, export_dir):
     """ Given a list of references in either list or dict format,
     determin which references were saved locally and saves those to
     the appropriate location in the export directory  """
     if not export_dir:
         return references
     relative_base_path = os.path.join(self.system_key, self.component_key)
     output_base_path = os.path.join(export_dir, relative_base_path)
     utils.create_dir(output_base_path)
     for reference in utils.inplace_gen(references):
         path = reference.get('path', 'NONE')
         file_import_path = os.path.join(self.component_directory, path)
         is_local = not ('http://' in file_import_path or 'https://' in file_import_path)
         if os.path.exists(file_import_path) and is_local:
             # Create dir and copy file
             file_output_path = os.path.join(output_base_path, path)
             utils.create_dir(os.path.dirname(file_output_path))
             shutil.copy(file_import_path, file_output_path)
             # Rename path
             file_relative_path = os.path.join(relative_base_path, path)
             reference['path'] = file_relative_path
     return references