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)
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)
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)