Exemple #1
0
 def add_local(self, library_id, is_natives, source_paths, destination_path):
     '''
     source_paths is a list
     if regular library, then it should contain one string to a jar
     if natives, then it should contain paths to all natives directories
     Destination path is a path to a jar or directory (for regular or natives, respectively)
     '''
     if library_id in self.index:
         raise Exception("Library already exists") # TODO: More appropriate exception
     if isinstance(destination_path, list):
         final_path = self.BASE_PATH.joinpath(*destination_path)
     else:
         final_path = pathlib.Path(destination_path) # Assuming absolute
     if is_natives:
         for current_source in source_paths:
             try:
                 FileTools.copy(current_source, str(final_path.joinpath(FileTools.get_file_name(current_source))))
             except FileExistsError:
                 pass
     else:
         FileTools.copy(source_paths[0], str(final_path))
     self.index[library_id] = dict()
     self.index[library_id]["path"] = list(final_path.relative_to(self.BASE_PATH).parts)
     self._flush_index()