fix: some bug
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2024-05-06 10:31:21 +02:00
parent a7711761f9
commit d9105fb55a
3 changed files with 12 additions and 24 deletions

View File

@@ -166,41 +166,30 @@ class Collection(Generic[T]):
object_trace(f"Appending {other.option_string} to {self}")
push_to: Optional[Tuple[Collection, T]] = None
for c in self.push_to:
r = c._find_object(other)
if r is not None:
push_to_collection = (c, r)
output("found push to", found, other, self, color=BColors.RED, sep="\t")
break
output("found push to", r, other, self, color=BColors.RED, sep="\t")
return c.append(other, **kwargs)
pull_from: Optional[Tuple[Collection, T]] = None
for c in self.pull_from:
r = c._find_object(other)
if r is not None:
pull_from_collection = (c, r)
output("found pull from", found, other, self, color=BColors.RED, sep="\t")
output("found pull from", r, other, self, color=BColors.RED, sep="\t")
other.merge(r, **kwargs)
c.remove(r, **kwargs)
break
if pull_from is not None:
pull_from[0].remove(pull_from[1])
existing_object = self._find_object(other, no_push_to=kwargs.get("no_push_to", False))
if existing_object is None:
if push_to is None:
self._append_new_object(other, **kwargs)
else:
push_to[0]._merge_into_contained_object(push_to[1], other, **kwargs)
if pull_from is not None:
self._merge_into_contained_object(other if push_to is None else push_to[1], pull_from[1], **kwargs)
self._append_new_object(other, **kwargs)
else:
self._merge_into_contained_object(existing_object, other, **kwargs)
if pull_from is not None:
self._merge_into_contained_object(existing_object, pull_from[1], **kwargs)
existing_object.merge(other, **kwargs)
def remove(self, *other_list: List[T], silent: bool = False):
def remove(self, *other_list: List[T], silent: bool = False, **kwargs):
for other in other_list:
existing: Optional[T] = self._indexed_values["id"].get(other.id, None)
if existing is None:
@@ -208,11 +197,13 @@ class Collection(Generic[T]):
raise ValueError(f"Object {other} not found in {self}")
return other
"""
for collection_attribute, generator in self.extend_object_to_attribute.items():
other.__getattribute__(collection_attribute).remove(*generator, silent=silent, **kwargs)
for attribute, new_object in self.append_object_to_attribute.items():
other.__getattribute__(attribute).remove(new_object, silent=silent, **kwargs)
"""
self._data.remove(existing)
self._unmap_element(existing)