コード例 #1
0
def get_property_names(obj):
    if hasattr(obj, "property_dict"):
        return obj.property_dict.keys()
    return [
        name for name in get_all_params(obj)
        if isinstance(obj.get_member(name), Property)
    ]
コード例 #2
0
def process_kwargs(self, kwargs):
    """Goes through all_params and sets the attribute if it is included in kwargs, also popping it out of kwargs.
    if the param is tagged with "former", the kwarg is added back using the value of the param. Returns the processed kwargs"""
    for arg in get_all_params(self):  #get_all_tags(self, "former"):
        if arg in kwargs:
            setattr(self, arg, kwargs[arg])
        val = kwargs.pop(arg, None)
        key = get_tag(self, arg, "former", False)
        if key is not False:
            if val is None:
                val = getattr(self, arg)
            kwargs[key] = val
    return kwargs
コード例 #3
0
def process_kwargs(self, kwargs):
    """Goes through all_params and sets the attribute if it is included in kwargs, also popping it out of kwargs.
    if the param is tagged with "former", the kwarg is added back using the value of the param. Returns the processed kwargs"""
    for arg in get_all_params(self): #get_all_tags(self, "former"):
        if arg in kwargs:
            setattr(self, arg, kwargs[arg])
        val=kwargs.pop(arg, None)
        key=get_tag(self, arg, "former", False)
        if key is not False:
            if val is None:
                val=getattr(self, arg)
            kwargs[key]=val
    return kwargs
コード例 #4
0
 def __init__(self, **kwargs):
     super(Test, self).__init__(**kwargs)
     for param in get_all_params(self):
         typer=get_type(self, param)
         _setup_property_fs(self, param, typer)
コード例 #5
0
    a=Int().tag(c=4, private=True)
    b=Float()
    c=Int().tag(sub=True)

    @private_property
    def main_params(self):
        return ["c"]
t=Test()
print
print "get_reserved_names returns all names of members tagged as private=True"
print 'get_reserved_names(t)'
print get_reserved_names(t)
print
print "get_all_params returns all names of members not tagged as private=True"
print 'get_all_params(t)'
print get_all_params(t)
print
print "get_all_main_params returns all params in all_params that are not tagged as sub"
print 'get_all_main_params(t)'
print get_all_main_params(t)
print
print "get_main_params defaults to get_all main_params but can be overwritten in the class"
print 'get_main_params(t)'
print get_main_params(t)

print
log_info("test code:")
print """class Test(Atom):
    a=Int().tag(c=4)
    b=Int().tag(typer=str)
t=Test()"""
コード例 #6
0
ファイル: backbone.py プロジェクト: priyanka27s/TA_software
 def all_params(self):
     return get_all_params(self)
コード例 #7
0
ファイル: backbone.py プロジェクト: thomasaref/TA_software
 def all_params(self):
     return get_all_params(self)
コード例 #8
0
 def __init__(self, **kwargs):
     super(Test, self).__init__(**kwargs)
     for param in get_all_params(self):
         typer = get_type(self, param)
         _setup_property_fs(self, param, typer)
コード例 #9
0
    c = Int().tag(sub=True)

    @private_property
    def main_params(self):
        return ["c"]


t = Test()
print
print "get_reserved_names returns all names of members tagged as private=True"
print 'get_reserved_names(t)'
print get_reserved_names(t)
print
print "get_all_params returns all names of members not tagged as private=True"
print 'get_all_params(t)'
print get_all_params(t)
print
print "get_all_main_params returns all params in all_params that are not tagged as sub"
print 'get_all_main_params(t)'
print get_all_main_params(t)
print
print "get_main_params defaults to get_all main_params but can be overwritten in the class"
print 'get_main_params(t)'
print get_main_params(t)

print
log_info("test code:")
print """class Test(Atom):
    a=Int().tag(c=4)
    b=Int().tag(typer=str)
t=Test()"""
コード例 #10
0
ファイル: aaaa.py プロジェクト: priyanka27s/TA_software
def get_property_names(obj):
    if hasattr(obj, "property_dict"):
        return obj.property_dict.keys()
    return [name for name in get_all_params(obj) if isinstance(obj.get_member(name), Property)]