<s> """<STR_LIT>""" <EOL> __all__ = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> import binascii <EOL> import sys <EOL> import urlparse <EOL> import logging <EOL> from urllib import urlencode <EOL> elementtree_modules = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> def toUnicode ( value ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( value , str ) : <EOL> return value . decode ( '<STR_LIT:utf-8>' ) <EOL> return unicode ( value ) <EOL> def autoSubmitHTML ( form , title = '<STR_LIT>' ) : <EOL> return """<STR_LIT>""" % ( title , form ) <EOL> def importElementTree ( module_names = None ) : <EOL> """<STR_LIT>""" <EOL> if module_names is None : <EOL> module_names = elementtree_modules <EOL> for mod_name in module_names : <EOL> try : <EOL> ElementTree = __import__ ( mod_name , None , None , [ '<STR_LIT>' ] ) <EOL> except ImportError : <EOL> pass <EOL> else : <EOL> try : <EOL> ElementTree . XML ( '<STR_LIT>' ) <EOL> except ( SystemExit , MemoryError , AssertionError ) : <EOL> raise <EOL> except : <EOL> logging . exception ( '<STR_LIT>' <EOL> '<STR_LIT>' % mod_name ) <EOL> else : <EOL> return ElementTree <EOL> else : <EOL> raise ImportError ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % ( module_names , ) <EOL> ) <EOL> def log ( message , level = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> logging . error ( "<STR_LIT>" <EOL> "<STR_LIT>" , message ) <EOL> def appendArgs ( url , args ) : <EOL> """<STR_LIT>""" <EOL> if hasattr ( args , '<STR_LIT>' ) : <EOL> args = args . items ( ) <EOL> args . sort ( ) <EOL> else : <EOL> args = list ( args ) <EOL> if len ( args ) == <NUM_LIT:0> : <EOL> return url <EOL> if '<STR_LIT:?>' in url : <EOL> sep = '<STR_LIT:&>' <EOL> else : <EOL> sep = '<STR_LIT:?>' <EOL> i = <NUM_LIT:0> <EOL> for k , v in args : <EOL> if type ( k ) is not str : <EOL> k = k . encode ( '<STR_LIT>' ) <EOL> if type ( v ) is not str : <EOL> v = v . encode ( '<STR_LIT>' ) <EOL> args [ i ] = ( k , v ) <EOL> i += <NUM_LIT:1> <EOL> return '<STR_LIT>' % ( url , sep , urlencode ( args ) ) <EOL> def toBase64 ( s ) : <EOL> """<STR_LIT>""" <EOL> return binascii . b2a_base64 ( s ) [ : - <NUM_LIT:1> ] <EOL> def fromBase64 ( s ) : <EOL> try : <EOL> return binascii . a2b_base64 ( s ) <EOL> except binascii . Error , why : <EOL> raise ValueError ( why [ <NUM_LIT:0> ] ) <EOL> class Symbol ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , name ) : <EOL> self . name = name <EOL> def __eq__ ( self , other ) : <EOL> return type ( self ) is type ( other ) and self . name == other . name <EOL> def __ne__ ( self , other ) : <EOL> return not ( self == other ) <EOL> def __hash__ ( self ) : <EOL> return hash ( ( self . __class__ , self . name ) ) <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % ( self . name , ) </s>
