<s> """<STR_LIT>""" <EOL> import uuid <EOL> class Node ( object ) : <EOL> """<STR_LIT>""" <EOL> ( ADD , DELETE , INSERT ) = list ( range ( <NUM_LIT:3> ) ) <EOL> def __init__ ( self , tag = None , identifier = None , expanded = True , data = None ) : <EOL> """<STR_LIT>""" <EOL> self . _identifier = None <EOL> self . _set_identifier ( identifier ) <EOL> if tag is None : <EOL> self . _tag = self . _identifier <EOL> else : <EOL> self . _tag = tag <EOL> self . expanded = expanded <EOL> self . _bpointer = None <EOL> self . _fpointer = list ( ) <EOL> self . data = data <EOL> def __lt__ ( self , other ) : <EOL> return self . tag < other . tag <EOL> def _set_identifier ( self , nid ) : <EOL> """<STR_LIT>""" <EOL> if nid is None : <EOL> self . _identifier = str ( uuid . uuid1 ( ) ) <EOL> else : <EOL> self . _identifier = nid <EOL> @ property <EOL> def bpointer ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _bpointer <EOL> @ bpointer . setter <EOL> def bpointer ( self , nid ) : <EOL> """<STR_LIT>""" <EOL> if nid is not None : <EOL> self . _bpointer = nid <EOL> else : <EOL> self . _bpointer = None <EOL> @ property <EOL> def fpointer ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _fpointer <EOL> @ fpointer . setter <EOL> def fpointer ( self , value ) : <EOL> """<STR_LIT>""" <EOL> if value is None : <EOL> self . _fpointer = list ( ) <EOL> elif isinstance ( value , list ) : <EOL> self . _fpointer = value <EOL> elif isinstance ( value , dict ) : <EOL> self . _fpointer = list ( value . keys ( ) ) <EOL> elif isinstance ( value , set ) : <EOL> self . _fpointer = list ( value ) <EOL> else : <EOL> pass <EOL> @ property <EOL> def identifier ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _identifier <EOL> @ identifier . setter <EOL> def identifier ( self , value ) : <EOL> """<STR_LIT>""" <EOL> if value is None : <EOL> print ( "<STR_LIT>" ) <EOL> else : <EOL> self . _set_identifier ( value ) <EOL> def is_leaf ( self ) : <EOL> """<STR_LIT>""" <EOL> if len ( self . fpointer ) == <NUM_LIT:0> : <EOL> return True <EOL> else : <EOL> return False <EOL> def is_root ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _bpointer is None <EOL> @ property <EOL> def tag ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _tag <EOL> @ tag . setter <EOL> def tag ( self , value ) : <EOL> """<STR_LIT>""" <EOL> self . _tag = value if value is not None else None <EOL> def update_bpointer ( self , nid ) : <EOL> """<STR_LIT>""" <EOL> self . bpointer = nid <EOL> def update_fpointer ( self , nid , mode = ADD ) : <EOL> """<STR_LIT>""" <EOL> if nid is None : <EOL> return <EOL> if mode is self . ADD : <EOL> self . _fpointer . append ( nid ) <EOL> elif mode is self . DELETE : <EOL> if nid in self . _fpointer : <EOL> self . _fpointer . remove ( nid ) <EOL> elif mode is self . INSERT : <EOL> print ( "<STR_LIT>" ) <EOL> self . update_fpointer ( nid ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> pass </s>
