How to use the py2neo.packages.jsonstream.assembled function in py2neo

To help you get started, we’ve selected a few py2neo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github technige / py2neo / py2neo / legacy / index.py View on Github external
def get(self, key, value):
        """ Fetch a list of all entities from the index which are associated
        with the `key`:`value` pair supplied::

            # obtain a reference to the "People" node index and
            # get all nodes where `family_name` equals "Smith"
            people = graph.get_or_create_index(neo4j.Node, "People")
            smiths = people.get("family_name", "Smith")

        ..
        """
        return [
            self.graph.hydrate(assembled(result))
            for i, result in grouped(self._searcher.expand(key=key, value=value).get())
        ]
github technige / py2neo / py2neo / legacy / index.py View on Github external
alice = contacts.get_or_create("name", "SMITH, Alice", {
                "given_name": "Alice Jane", "family_name": "Smith",
                "phone": "01234 567 890", "mobile": "07890 123 456"
            })

            # obtain a reference to the "Friendships" relationship index and
            # ensure that Alice and Bob's friendship is registered (`alice`
            # and `bob` refer to existing nodes)
            friendships = graph.get_or_create_index(neo4j.Relationship, "Friendships")
            alice_and_bob = friendships.get_or_create(
                "friends", "Alice & Bob", (alice, "KNOWS", bob)
            )

        ..
        """
        return self.graph.hydrate(assembled(self._create_unique(key, value, abstract)))
github technige / py2neo / py2neo / ext / spatial / plugin.py View on Github external
def _execute_spatial_request(self, resource, spatial_payload):
        try:
            json_stream = resource.post(spatial_payload)
        except GraphError as exc:
            if 'NullPointerException' in exc.full_name:
                # no results leads to a NullPointerException.
                # this is probably a bug on the Java side, but this
                # happens with some resources and must be managed.
                return []
            raise

        if json_stream.status_code == 204:
            # no content
            return []

        geometry_nodes = map(Node.hydrate, assembled(json_stream))
        nodes = self._get_data_nodes(geometry_nodes)

        return nodes
github technige / py2neo / py2neo / neo4j.py View on Github external
def relationship_types(self):
        """ The set of relationship types currently defined within the graph.
        """
        resource = self._subresource("relationship_types")
        return set(_hydrated(assembled(resource._get())))
github technige / py2neo / py2neo / ext / spatial / plugin.py View on Github external
def create_layer(self, layer_name):
        """ Create a Layer to add geometries to. If a Layer with the
        name property value of ``layer_name`` already exists, nothing
        happens.

        """
        resource = self.resources['addEditableLayer']
        spatial_data = dict(layer=layer_name, **EXTENSION_CONFIG)
        raw = resource.post(spatial_data)
        layer = assembled(raw)

        return layer
github technige / py2neo / py2neo / neo4j.py View on Github external
def __iter__(self):
        hydration_cache = {}
        for key, section in grouped(self._buffered):
            if key[0] == "data":
                for i, row in grouped(section):
                    yield self._producer.produce(_hydrated(assembled(row),
                                                           hydration_cache))
github technige / py2neo / py2neo / neo4j.py View on Github external
def get_properties(self):
        """ Fetch all properties.

        :return: dictionary of properties
        """
        if not self.is_abstract:
            self._properties = assembled(self._properties_resource._get()) or {}
        return self._properties
github technige / py2neo / py2neo / neo4j.py View on Github external
def find(self, label, property_key=None, property_value=None):
        """ Iterate through a set of labelled nodes, optionally filtering
        by property key and value
        """
        uri = URI(self).resolve("/".join(["label", label, "nodes"]))
        if property_key:
            uri = uri.resolve("?" + percent_encode({property_key: json.dumps(property_value, ensure_ascii=False)}))
        try:
            for i, result in grouped(Resource(uri)._get()):
                yield _hydrated(assembled(result))
        except ClientError as err:
            if err.status_code != NOT_FOUND:
                raise