How to use the py2neo.compat.ustr 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 / ext / batch / core.py View on Github external
def uri_string(self):
        """ The fully resolved URI string for this target.

        :rtype: string

        """
        if isinstance(self.entity, int):
            uri_string = "{{{0}}}".format(self.entity)
        elif isinstance(self.entity, NodePointer):
            uri_string = "{{{0}}}".format(self.entity.address)
        else:
            try:
                uri_string = self.entity.ref
            except AttributeError:
                uri_string = ustr(self.entity)
        if self.segments:
            if not uri_string.endswith("/"):
                uri_string += "/"
            uri_string += "/".join(map(percent_encode, self.segments))
        return uri_string
github technige / py2neo / py2neo / graph.py View on Github external
def apply(x):
        if isinstance(x, dict):
            inst.update(x)
        elif is_collection(x):
            for item in x:
                apply(item)
        elif isinstance(x, string):
            inst.labels().add(ustr(x))
        else:
            raise TypeError("Cannot cast %s to Node" % obj.__class__.__name__)
github technige / py2neo / py2neo / cypher / writer.py View on Github external
def write_literal(self, text):
        """ Write literal text.

        :arg text:
        """
        self.file.write(ustr(text))
github technige / py2neo / py2neo / cypher / delete.py View on Github external
def _(*args):
    return "".join("_" + ustr(arg) for arg in args)
github technige / py2neo / py2neo / cypher / create.py View on Github external
def _(*args):
    return "".join("_" + ustr(arg) for arg in args)
github technige / py2neo / py2neo / cypher / delete.py View on Github external
def _delete_path(self, path, name):
        for i, rel in enumerate(path.relationships()):
            self._delete_relationship(rel, name + "r" + ustr(i))
        for i, node in enumerate(path.nodes()):
            self._delete_node(node, name + "n" + ustr(i))
github technige / py2neo / py2neo / cypher / lang.py View on Github external
def write_identifier(self, identifier):
        """ Write an identifier.
        """
        if not identifier:
            raise ValueError("Invalid identifier")
        identifier = ustr(identifier)
        safe = (identifier[0] in self.safe_first_chars and
                all(ch in self.safe_chars for ch in identifier[1:]))
        if not safe:
            self.file.write("`")
            self.file.write(identifier.replace("`", "``"))
            self.file.write("`")
        else:
            self.file.write(identifier)
github technige / py2neo / py2neo / cypher / lang.py View on Github external
def write_literal(self, text):
        """ Write literal text.
        """
        self.file.write(ustr(text))