Esempio n. 1
0
    def tag(ea, *args, **kwds):
        '''tag(ea, key?, value?) -> fetches/stores a tag from specified address'''
        try:
            context = function.top(ea)

        except ValueError:
            context = None

        if len(args) == 0 and len(kwds) == 0:
            result = datastore.address(context).select(query.address(ea))
            try:
                result = result[address]
            except:
                result = {}
            return result

        elif len(args) == 1:
            key, = args
            result = datastore.address(context).select(query.address(ea),
                                                       query.attribute(key))
            try:
                result = result[address][key]
            except:
                raise KeyError((hex(ea), key))
            return result

        if len(args) > 0:
            key, value = args
            kwds.update({key: value})
        return datastore.address(context).address(ea).set(**kwds)
Esempio n. 2
0
def tag(address, *args, **kwds):
    '''tag(address, key?, value?) -> fetches/stores a tag from specified address'''
    try:
        context = function.top(address)

    except ValueError:
        context = None

    if len(args) == 0 and len(kwds) == 0:
#        result = __datastore.content.select(context, query.address(address))
        result = datastore.address(context).select(query.address(address))
        try:
            result = result[address]
        except:
            result = {}
        return result

    elif len(args) == 1:
        key, = args
#        result = __datastore.content.select(context, query.address(address), query.attribute(key))
        result = datastore.address(context).select(query.address(address), query.attribute(key))
        try:
            result = result[address][key]
        except:
            raise KeyError( (hex(address),key) )
            result = None
        return result

    if len(args) > 0:
        key,value = args
        kwds.update({key:value})
    return datastore.address(context).address(address).set(**kwds)
Esempio n. 3
0
    def tag(address, *args, **kwds):
        '''tag(address, key?, value?) -> fetches/stores a tag from a function's comment'''
        if len(args) == 0:
            return datastore.address(address)

        elif len(args) == 1:
            key, = args
            result = datastore.select(query.address(address), query.attribute(key)).values()
            try:
                result = result[0][key]
            except:
                raise KeyError(hex(address),key)
            return result

        key,value = args
        kwds.update({key:value})
        return datastore.address(address).set(**kwds)
Esempio n. 4
0
    def tag(address, *args, **kwds):
        '''tag(address, key?, value?) -> fetches/stores a tag from a function's comment'''
        if len(args) == 0:
            return datastore.address(address)

        elif len(args) == 1:
            key, = args
            result = datastore.select(query.address(address), query.attribute(key)).values()
            try:
                result = result[0][key]
            except:
                raise KeyError(hex(address),key)
            return result

        key,value = args
        kwds.update({key:value})
        return datastore.address(address).set(**kwds)
Esempio n. 5
0
 def getAttribute(self, name):
     return self.store.select(q.attribute(name))