def _clone_version(self, orig_id, orig_type, clone_id, clone_type): orig_paths = self.get_paths(orig_id, orig_type) clone_paths = self.get_paths(clone_id, clone_type) FileTools.copy(orig_paths["jar"], clone_paths["jar"]) FileTools.copy(orig_paths["json"], clone_paths["json"]) current_listing = dict() current_listing["type"] = clone_type current_listing["name"] = clone_id self.index.append(current_listing) self._flush_index()
def install_custom(self, version_id, version_jar, version_json): if self.version_exists(version_id, "custom"): raise Exception("Version already exists") # TODO: More appropriate exception paths_dict = self.get_paths(version_id, "custom") FileTools.copy(version_jar, paths_dict["jar"]) FileTools.copy(version_json, paths_dict["json"]) current_listing = dict() current_listing["type"] = "custom" current_listing["name"] = version_id self.index.append(current_listing) self._flush_index()
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()