Exemple #1
0
 def __init__(
     self,
     name: t.Optional[str] = None,
     email: t.Optional[str] = None,
     userdata: t.Optional[Userdata] = None,
     id: t.Optional[str] = None,
 ) -> None:
     self.name = name
     self.email = email
     self.userdata = userdata or {}
     self._id = id or utils.uuid()
Exemple #2
0
    def __init__(
        self,
        metadata: t.Optional[Metadata] = None,
        userdata: t.Optional[Userdata] = None,
        id: t.Optional[str] = None,
    ):
        self._id = id or utils.uuid()
        self.metadata = metadata or Metadata()
        self.userdata = userdata or {}

        self.__post_init__()
Exemple #3
0
    def __init__(
        self,
        source: Node,
        target: Node,
        metadata: t.Optional[Metadata] = None,
        userdata: t.Optional[Userdata] = None,
        id: t.Optional[str] = None,
    ):
        # if isinstance(source, AtomNode) and isinstance(target, AtomNode):
        #     raise ValueError("Cannot create an edge between two atom nodes.")

        self._id = id or utils.uuid()
        self._source = source
        self._target = target
        self.metadata = metadata or Metadata()
        self.userdata = userdata or {}

        self.__post_init__()
Exemple #4
0
    def from_ova(
        cls,
        obj: ova.Edge,
        nodes: t.Mapping[str, Node],
    ) -> t.Optional[Edge]:
        """Generate Edge object from OVA Edge format."""
        source_id = str(obj["from"]["id"])
        target_id = str(obj["to"]["id"])
        date = dt.from_format(obj.get("date"),
                              ova.DATE_FORMAT) or pendulum.now()

        if source_id in nodes and target_id in nodes:
            return cls(
                id=utils.uuid(),
                source=nodes[source_id],
                target=nodes[target_id],
                metadata=Metadata(date, date),
            )

        return None
Exemple #5
0
 def __init__(
     self,
     name: t.Optional[str] = None,
     username: t.Optional[str] = None,
     email: t.Optional[str] = None,
     url: t.Optional[str] = None,
     location: t.Optional[str] = None,
     description: t.Optional[str] = None,
     metadata: t.Optional[Metadata] = None,
     userdata: t.Optional[Userdata] = None,
     id: t.Optional[str] = None,
 ) -> None:
     self.name = name
     self.username = username
     self.email = email
     self.url = url
     self.location = location
     self.description = description
     self.metadata = metadata or Metadata()
     self.userdata = userdata or {}
     self._id = id or utils.uuid()