コード例 #1
0
ファイル: create.py プロジェクト: JohannesOos/py2neo
 def create_unique(self, entity):
     entity = Graph.cast(entity)
     index = len(self.entities)
     name = _(index)
     if isinstance(entity, Path):
         self.names.append(self.create_unique_path(entity, name))
     else:
         raise TypeError("Cannot create unique entity of type %s" % type(entity).__name__)
     self.entities.append(entity)
コード例 #2
0
ファイル: create.py プロジェクト: zrg1993/py2neo
 def create_unique(self, entity):
     entity = Graph.cast(entity)
     index = len(self.entities)
     name = _(index)
     if isinstance(entity, Path):
         self.names.append(self.create_unique_path(entity, name))
     else:
         raise TypeError("Cannot create unique entity of type %s" %
                         type(entity).__name__)
     self.entities.append(entity)
コード例 #3
0
ファイル: delete.py プロジェクト: zrg1993/py2neo
 def delete(self, entity):
     entity = Graph.cast(entity)
     index = len(self.entities)
     name = _(index)
     if isinstance(entity, Node):
         self.delete_node(entity, name)
     elif isinstance(entity, Relationship):
         self.delete_relationship(entity, name)
     elif isinstance(entity, Path):
         self.delete_path(entity, name)
     self.entities.append(entity)
コード例 #4
0
ファイル: delete.py プロジェクト: Sapphirine/stackexchange
    def delete(self, entity):
        """ Append an entity to the DELETE clause of this statement.

        :arg entity: The entity to delete.

        """
        entity = Graph.cast(entity)
        index = len(self.entities)
        name = _(index)
        if isinstance(entity, Node):
            self._delete_node(entity, name)
        elif isinstance(entity, Relationship):
            self._delete_relationship(entity, name)
        elif isinstance(entity, Path):
            self._delete_path(entity, name)
        self.entities.append(entity)
コード例 #5
0
    def delete(self, entity):
        """ Append an entity to the DELETE clause of this statement.

        :arg entity: The entity to delete.

        """
        entity = Graph.cast(entity)
        index = len(self.entities)
        name = _(index)
        if isinstance(entity, Node):
            self._delete_node(entity, name)
        elif isinstance(entity, Relationship):
            self._delete_relationship(entity, name)
        elif isinstance(entity, Path):
            self._delete_path(entity, name)
        self.entities.append(entity)
コード例 #6
0
ファイル: create.py プロジェクト: Sapphirine/stackexchange
    def create(self, entity):
        """ Append an entity to the CREATE clause of this statement.

        :arg entity: The entity to create.

        """
        entity = Graph.cast(entity)
        index = len(self.entities)
        name = _(index)
        if isinstance(entity, Node):
            self.names.append(self._create_node(entity, name))
        elif isinstance(entity, Path):
            self.names.append(self._create_path(entity, name, unique=False))
        else:
            raise TypeError("Cannot create entity of type %s" % type(entity).__name__)
        self.entities.append(entity)
コード例 #7
0
ファイル: create.py プロジェクト: LiuYuQ/beifen
    def create(self, entity):
        """ Append an entity to the CREATE clause of this statement.

        :arg entity: The entity to create.

        """
        entity = Graph.cast(entity)
        index = len(self.entities)
        name = _(index)
        if isinstance(entity, Node):
            self.names.append(self._create_node(entity, name))
        elif isinstance(entity, Path):
            self.names.append(self._create_path(entity, name, unique=False))
        else:
            raise TypeError("Cannot create entity of type %s" %
                            type(entity).__name__)
        self.entities.append(entity)
コード例 #8
0
ファイル: create.py プロジェクト: Sapphirine/stackexchange
    def create_unique(self, entity):
        """ Append an entity to the CREATE UNIQUE clause of this statement.

        :arg entity: The entity to add.

        """
        entity = Graph.cast(entity)
        index = len(self.entities)
        name = _(index)
        if isinstance(entity, Path):
            if len(entity) == 0:
                raise ValueError("Cannot create unique path with zero length")
            if not any(node.bound or node in self for node in entity.nodes):
                raise ValueError("At least one node must be bound to create a unique path")
            self.names.append(self._create_path(entity, name, unique=True))
        else:
            raise TypeError("Cannot create unique entity of type %s" % type(entity).__name__)
        self.entities.append(entity)
コード例 #9
0
ファイル: create.py プロジェクト: LiuYuQ/beifen
    def create_unique(self, entity):
        """ Append an entity to the CREATE UNIQUE clause of this statement.

        :arg entity: The entity to add.

        """
        entity = Graph.cast(entity)
        index = len(self.entities)
        name = _(index)
        if isinstance(entity, Path):
            if len(entity) == 0:
                raise ValueError("Cannot create unique path with zero length")
            if not any(node.bound or node in self for node in entity.nodes):
                raise ValueError(
                    "At least one node must be bound to create a unique path")
            self.names.append(self._create_path(entity, name, unique=True))
        else:
            raise TypeError("Cannot create unique entity of type %s" %
                            type(entity).__name__)
        self.entities.append(entity)