示例#1
0
 def __init__( me, e3):
     DictAttr.__init__( me, _text__= e3.text or '', **e3.attrib)
     for i in e3:
         tag = i.tag.rsplit('}',1)[-1]
         if tag in me:
             ii = me[ tag]
             if not isinstance( ii, list):
                 ii = me[ tag] = [ ii ]
             ii.append( e3obj( i))
         else:
             me[ tag] = e3obj( i)
示例#2
0
    def t0():
        e= DictAttr( a=2)
        e.c=4
        print( 'c' in e)
        print( 'd' in e)
        e['c']
        print( e)
        #e['d']

        e['c']=3
        print( 'c' in e)
        print( e)

        #e.update_pre( c=3)
        #print(object.__repr__( e))
        #print(object.__repr__( e.__dict__))
        print(e.c)
        print(e['c'])
示例#3
0
    def t0():
        e= DictAttr( a=2)
        assert ( e['a'] == 2 ),e
        assert ( e.a == 2 ) ,e
        assert len(e) == 1  ,e
        e.c=4
        assert ( 'c' in e)  ,e
        assert ( 'd' not in e),e
        assert len(e) == 2  ,e
        assert ( e.c == 4 ) ,e
        assert ( e['c'] == 4 ),e
        e['c']
        print( e)
        #e['d']

        e['c']=3
        assert ( 'c' in e)  ,e
        assert ( e.c == 3 ) ,e
        print( e)