<s> """<STR_LIT>""" <EOL> __docformat__ = "<STR_LIT>" <EOL> def xml_elements_equal ( element1 , element2 , ignore_level1_cdata = False ) : <EOL> """<STR_LIT>""" <EOL> if None in ( element1 , element2 ) or element1 . tag != element2 . tag : <EOL> return False <EOL> attrs1 = list ( element1 . items ( ) ) <EOL> attrs1 . sort ( ) <EOL> attrs2 = list ( element2 . items ( ) ) <EOL> attrs2 . sort ( ) <EOL> if not ignore_level1_cdata : <EOL> if element1 . text != element2 . text : <EOL> return False <EOL> if attrs1 != attrs2 : <EOL> return False <EOL> if len ( element1 ) != len ( element2 ) : <EOL> return False <EOL> for child1 , child2 in zip ( element1 , element2 ) : <EOL> if child1 . tag != child2 . tag : <EOL> return False <EOL> if not ignore_level1_cdata : <EOL> if element1 . text != element2 . text : <EOL> return False <EOL> if not xml_elements_equal ( child1 , child2 ) : <EOL> return False <EOL> return True <EOL> import time <EOL> import datetime <EOL> _MINUTE = datetime . timedelta ( minutes = <NUM_LIT:1> ) <EOL> _NULLDELTA = datetime . timedelta ( ) <EOL> def datetime_utc_to_local ( utc ) : <EOL> """<STR_LIT>""" <EOL> ts = time . time ( ) <EOL> cur = datetime . datetime . fromtimestamp ( ts ) <EOL> cur_utc = datetime . datetime . utcfromtimestamp ( ts ) <EOL> offset = cur - cur_utc <EOL> t = utc <EOL> d = datetime . timedelta ( hours = <NUM_LIT:2> ) <EOL> while d > _MINUTE : <EOL> local = t + offset <EOL> tm = local . timetuple ( ) <EOL> tm = tm [ <NUM_LIT:0> : <NUM_LIT:8> ] + ( <NUM_LIT:0> , ) <EOL> ts = time . mktime ( tm ) <EOL> u = datetime . datetime . utcfromtimestamp ( ts ) <EOL> diff = u - utc <EOL> if diff < _MINUTE and diff > - _MINUTE : <EOL> break <EOL> if diff > _NULLDELTA : <EOL> offset -= d <EOL> else : <EOL> offset += d <EOL> d //= <NUM_LIT:2> <EOL> return local <EOL> def datetime_local_to_utc ( local ) : <EOL> """<STR_LIT>""" <EOL> timestamp = time . mktime ( local . timetuple ( ) ) <EOL> return datetime . datetime . utcfromtimestamp ( timestamp ) </s>
