Exemplo n.º 1
0
    def __init__(self, formatdict, dburl=None, dronelist=None,
            dictclass=FancyDictObj, options=None, executor_context=None):
        '''Initialization
        Here are the main two things to understand:
            formatdict is a dict-like object which provides a format string
            for each kind of relationship and node.

            These format strings are then interpolated with the values
            from the relationship or node as filtered by @dictclass objects.
            The @dictclass object must behave like a dict. When format items
            are requested by a format in the formatdict, the dictclass object
            is expected to provide those values.
        params:
            @formatdict - dictionary providing format strings for
                          nodes and relationships
            @dburl - URL for opening the database
            @dronelist - a possibly-None list of drones to start from
            @dictclass - a dict-like class which can take a node or
                    relationship as a parameter for its constructor
                    along with extra keywords as the kw parameter.
        '''
        self.formatdict = formatdict
        self.store = assimcli.dbsetup(readonly=True, url=dburl)
        self.nodeids = None
        self.dictclass = dictclass
        self.options = options
        self.executor_context = executor_context
        if isinstance(dronelist, (str, unicode)):
            self.dronelist = [dronelist]
        else:
            self.dronelist = dronelist
    def __init__(self, formatdict, dburl=None, nodequeries=None,
            nodequeryparams=None, relquery=None, relqueryparams=None,
            dictclass=FancyDictObj, options=None):
        '''Initialization
        Here are the main two things to understand:
            formatdict is a dict-like object which provides a format string
            for each kind of relationship and node.

            These format strings are then interpolated with the values
            from the relationship or node as filtered by @dictclass objects.
            The @dictclass object must behave like a dict. When format items
            are requested by a format in the formatdict, the dictclass object
            is expected to provide those values.
        params:
            @formatdict - dictionary providing format strings for
                          nodes and relationships
            @dburl - URL for opening the database
            @nodequeries - a list of Cypher query strings (or a single string)
                            which enumerate all the desired nodes.
                            Defaults to all nodes.
            @nodequeryparams - parameters to plug into the queries
            @relquery - a Cypher query which enumerates all potentially
                    interesting relationships.
                    Defaults to all relationships.
            @dictclass - a dict-like class which can take a node or
                    relationship as a parameter for its constructor
                    along with extra keywords as the kw parameter.
        '''
        self.formatdict = formatdict
        self.store = dbsetup(readonly=True, url=dburl)
        self.nodeids = None
        self.dictclass = dictclass
        if nodequeries is None:
            nodequeries = ('START n=node(*) RETURN n', )
        if isinstance(nodequeries, (str, unicode)):
            nodequeries = (nodequeries, )
        self.nodequeries = nodequeries
        self.nodequeryparams = nodequeryparams
        if relquery is None:
            relquery = '''START fromnode=node(*) MATCH fromnode-[rel]->tonode
            RETURN rel
            '''
        self.relquery = relquery
        self.relqueryparams = relqueryparams
        self.options = options
Exemplo n.º 3
0
    def __init__(self,
                 formatdict,
                 dburl=None,
                 dronelist=None,
                 dictclass=FancyDictObj,
                 options=None,
                 executor_context=None):
        '''Initialization
        Here are the main two things to understand:
            formatdict is a dict-like object which provides a format string
            for each kind of relationship and node.

            These format strings are then interpolated with the values
            from the relationship or node as filtered by @dictclass objects.
            The @dictclass object must behave like a dict. When format items
            are requested by a format in the formatdict, the dictclass object
            is expected to provide those values.
        params:
            @formatdict - dictionary providing format strings for
                          nodes and relationships
            @dburl - URL for opening the database
            @dronelist - a possibly-None list of drones to start from
            @dictclass - a dict-like class which can take a node or
                    relationship as a parameter for its constructor
                    along with extra keywords as the kw parameter.
        '''
        self.formatdict = formatdict
        self.store = assimcli.dbsetup(readonly=True, url=dburl)
        self.nodeids = None
        self.dictclass = dictclass
        self.options = options
        self.executor_context = executor_context
        if isinstance(dronelist, (str, unicode)):
            self.dronelist = [dronelist]
        else:
            self.dronelist = dronelist