diff --git a/src/caoscrawler/identifiable.py b/src/caoscrawler/identifiable.py index d7bccac7a483c2e2e6feca4c2bf9a9bfc8685ff9..f6c85c694e5ef0be7e6a9be8154a34c400bab008 100644 --- a/src/caoscrawler/identifiable.py +++ b/src/caoscrawler/identifiable.py @@ -53,19 +53,10 @@ class Identifiable(): backrefs: list, TODO future """ - -<< << << < HEAD - def __init__(self, record_id: Optional[int] = None, path: Optional[str] = None, - record_type: Optional[str] = None, + def __init__(self, record_id: Optional[int] = None, record_type: Optional[str] = None, name: Optional[str] = None, properties: Optional[dict] = None, backrefs: Optional[list[Union[int, str]]] = None): - if (record_id is None and path is None and name is None -== == === - def __init__(self, record_id: int=None, record_type: str=None, - name: str=None, properties: dict=None, - backrefs: list[Union[int, str]]=None): if (record_id is None and name is None ->> >>>> > dev and (backrefs is None or len(backrefs) == 0) and (properties is None or len(properties) == 0)): raise ValueError( @@ -74,17 +65,17 @@ class Identifiable(): if properties is not None and 'name' in [k.lower() for k in properties.keys()]: raise ValueError("Please use the separete 'name' keyword instead of the properties " "dict for name") - self.record_id=record_id - self.record_type=record_type - self.name=name + self.record_id = record_id + self.record_type = record_type + self.name = name if name == "": - self.name=None - self.properties: dict={} + self.name = None + self.properties: dict = {} if properties is not None: - self.properties=properties - self.backrefs: list[Union[int, db.Entity]]=[] + self.properties = properties + self.backrefs: list[Union[int, db.Entity]] = [] if backrefs is not None: - self.backrefs=backrefs + self.backrefs = backrefs def get_representation(self) -> str: return sha256(Identifiable._create_hashable_string(self).encode('utf-8')).hexdigest() @@ -118,7 +109,7 @@ class Identifiable(): creates a string from the attributes of an identifiable that can be hashed String has the form "P<parent>N<name>R<reference-ids>a:5b:10" """ - rec_string="P<{}>N<{}>R<{}>".format( + rec_string = "P<{}>N<{}>R<{}>".format( identifiable.record_type, identifiable.name, [Identifiable._value_representation(el) for el in identifiable.backrefs]) @@ -141,7 +132,7 @@ class Identifiable(): def __repr__(self): """ deterministic text representation of the identifiable """ - pstring=json.dumps({k: str(v) for k, v in self.properties.items()}) + pstring = json.dumps({k: str(v) for k, v in self.properties.items()}) return (f"{self.__class__.__name__} for RT {self.record_type}: id={self.record_id}; " f"name={self.name}\n" f"\tproperties:\n{pstring}\n"