def getter(self, data, enum): if not enum: return ProxyProperty(data) else: data = getattr(self._object, data, None) try: data = int(data) return Zuul.info(enum[data]) except Exception: return Zuul.info(data)
def test_Zuuldotinfo(self): isinfo = lambda x:isinstance(x, TargetInfo) single = Zuul.info(Target()) alist = Zuul.info([Target(), Target()]) adict = Zuul.info({'a':Target(), 'b':Target()}) nested = Zuul.info([{'a':[Target()], 'b':Target()}]) self.assert_(isinfo(single)) self.assert_(isinstance(alist, list)) for ob in alist: self.assert_(isinfo(ob)) self.assert_(isinstance(adict, dict)) for k, v in adict.items(): self.assert_(isinfo(v)) self.assert_(isinstance(nested, list))
def test_Zuuldotinfo(self): isinfo = lambda x: isinstance(x, TargetInfo) single = Zuul.info(Target()) alist = Zuul.info([Target(), Target()]) adict = Zuul.info({'a': Target(), 'b': Target()}) nested = Zuul.info([{'a': [Target()], 'b': Target()}]) self.assert_(isinfo(single)) self.assert_(isinstance(alist, list)) for ob in alist: self.assert_(isinfo(ob)) self.assert_(isinstance(adict, dict)) for k, v in adict.items(): self.assert_(isinfo(v)) self.assert_(isinstance(nested, list))
def getter(self): try: result = Zuul.info(getattr(self._object, method_name)()) except TypeError: # If not callable avoid the traceback and send the property result = Zuul.info(getattr(self._object, method_name)) if entity: # rather than returning entire object(s), return just # the fields needed by the UI renderer for creating links. return marshal(result, keys=('name', 'meta_type', 'class_label', 'uid')) else: if enum and isinstance(enum, dict): try: return enum.get(int(result), 'Unknown') except Exception: return result else: return result
def getter(self): return Zuul.info(getattr(self._object, relationship_name)())
def getter(self): # rather than returning entire object(s), return just the fields # required by the UI renderer for creating links. return marshal(Zuul.info(getattr(self._object, relationship_name)()), keys=('name', 'meta_type', 'class_label', 'uid'))
def info(f, *args, **kwargs): result = f(*args, **kwargs) return Zuul.info(result, adapterName=adapterName)
def info(f, *args, **kwargs): """ Apply Zuul.info to results. """ result = f(*args, **kwargs) return Zuul.info(result)