Trying to construct modelspace
This commit is contained in:
@@ -21,25 +21,21 @@ class ModelSpace:
|
||||
|
||||
self.selector = ModelPackageSelector(self.repo.model_sub_repo, set(self.installed_packages))
|
||||
self.temp_installed_resources = self.installed_resources
|
||||
self.temp_files_pending = SetsDict()
|
||||
self.temp_file_conflicts = SetsDict()
|
||||
|
||||
def _reset_selector(self):
|
||||
self.selector = ModelPackageSelector(self.repo.model_sub_repo, set(self.installed_packages))
|
||||
self.temp_installed_resources = self.installed_resources
|
||||
self.temp_files_pending = SetsDict()
|
||||
self.temp_file_conflicts = SetsDict()
|
||||
|
||||
|
||||
def check_for_file_conflicts(self, path: str | list[str]) -> list:
|
||||
# TODO
|
||||
raise NotImplemented
|
||||
# conflicts = []
|
||||
# if not isinstance(path, list): path = [path]
|
||||
# for p in path:
|
||||
# fullpath = Path(self.path) / p
|
||||
# if fullpath.exists() or p in self.temp['pending_files'].index: conflicts.append(p)
|
||||
# return conflicts
|
||||
|
||||
|
||||
|
||||
|
||||
def check_for_file_conflicts(self, pkg_id, path: str):
|
||||
path = Path(path)
|
||||
self.temp_files_pending.add(pkg_id, path)
|
||||
if path.exists() or path in self.temp_files_pending.index:
|
||||
self.temp_file_conflicts.add(pkg_id, path)
|
||||
|
||||
def get_dest_dir(self, package: ModelPackage, no_lineage = False):
|
||||
type_subdir = self.layout.get(package.package_type, None)
|
||||
@@ -80,7 +76,11 @@ class ModelSpace:
|
||||
for file in package.files:
|
||||
files.add(package.uuid, Path(self.get_dest_dir(package, self.layout.no_lineage)) / file)
|
||||
|
||||
for file in files.index: self.check_for_file_conflicts(file)
|
||||
for pkg_id in files.keys:
|
||||
for file in files.by_key(pkg_id):
|
||||
self.check_for_file_conflicts(pkg_id, file)
|
||||
|
||||
if len(self.temp_file_conflicts.index) != 0: raise RuntimeError("File conflicts detected")
|
||||
|
||||
# TODO run copier
|
||||
|
||||
|
||||
Reference in New Issue
Block a user