<s> """<STR_LIT>""" <EOL> import os , re , sys , platform , pkgutil <EOL> from re import escape <EOL> from path import path <EOL> def capitalize ( s ) : <EOL> """<STR_LIT>""" <EOL> return s [ <NUM_LIT:0> ] . upper ( ) + s [ <NUM_LIT:1> : ] <EOL> def uncapitalize ( s , preserveAcronymns = False ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> if preserveAcronymns and s [ <NUM_LIT:0> : <NUM_LIT:2> ] . isupper ( ) : <EOL> return s <EOL> except IndexError : pass <EOL> return s [ <NUM_LIT:0> ] . lower ( ) + s [ <NUM_LIT:1> : ] <EOL> def unescape ( s ) : <EOL> """<STR_LIT>""" <EOL> chars = [ r'<STR_LIT:">' , r"<STR_LIT:'>" ] <EOL> for char in chars : <EOL> tokens = re . split ( r'<STR_LIT>' + char , s ) <EOL> for i in range ( <NUM_LIT:1> , len ( tokens ) , <NUM_LIT:2> ) : <EOL> if tokens [ i ] : <EOL> tokens [ i ] = tokens [ i ] [ : - <NUM_LIT:1> ] + '<STR_LIT:">' <EOL> s = '<STR_LIT>' . join ( tokens ) <EOL> return s <EOL> def cacheProperty ( getter , attr_name , fdel = None , doc = None ) : <EOL> """<STR_LIT>""" <EOL> def fget ( obj ) : <EOL> val = None <EOL> if hasattr ( obj , attr_name ) : <EOL> val = getattr ( obj , attr_name ) <EOL> if val is None : <EOL> val = getter ( obj ) <EOL> setattr ( obj , attr_name , val ) <EOL> return val <EOL> def fset ( obj , val ) : <EOL> setattr ( obj , attr_name , val ) <EOL> return property ( fget , fset , fdel , doc ) <EOL> def timer ( command = '<STR_LIT>' , number = <NUM_LIT:10> , setup = '<STR_LIT>' ) : <EOL> import timeit <EOL> t = timeit . Timer ( command , setup ) <EOL> time = t . timeit ( number = number ) <EOL> print "<STR_LIT>" % time <EOL> return time <EOL> def toZip ( directory , zipFile ) : <EOL> """<STR_LIT>""" <EOL> import zipfile <EOL> zipFile = path ( zipFile ) <EOL> if zipFile . exists ( ) : zipFile . remove ( ) <EOL> z = zipfile . ZipFile ( <EOL> zipFile , '<STR_LIT:w>' , compression = zipfile . ZIP_DEFLATED <EOL> ) <EOL> if not directory . endswith ( os . sep ) : <EOL> directory += os . sep <EOL> directory = path ( directory ) <EOL> for subdir in directory . dirs ( '<STR_LIT>' ) + [ directory ] : <EOL> print "<STR_LIT>" , subdir <EOL> for fname in subdir . files ( '<STR_LIT>' ) : <EOL> archiveName = fname . replace ( directory , '<STR_LIT>' ) <EOL> z . write ( fname , archiveName , zipfile . ZIP_DEFLATED ) <EOL> z . close ( ) <EOL> return zipFile <EOL> def interpreterBits ( ) : <EOL> """<STR_LIT>""" <EOL> return struct . calcsize ( "<STR_LIT:P>" ) * <NUM_LIT:8> <EOL> return int ( re . match ( r"<STR_LIT>" , platform . architecture ( ) [ <NUM_LIT:0> ] ) . group ( <NUM_LIT:1> ) ) <EOL> def subpackages ( packagemod ) : <EOL> """<STR_LIT>""" <EOL> modpkgs = [ ] <EOL> modpkgs_names = set ( ) <EOL> if hasattr ( packagemod , '<STR_LIT>' ) : <EOL> yield packagemod . __name__ , packagemod , True <EOL> for importer , modname , ispkg in pkgutil . walk_packages ( packagemod . __path__ , packagemod . __name__ + '<STR_LIT:.>' ) : <EOL> if modname not in sys . modules : <EOL> try : <EOL> mod = importer . find_module ( modname ) . load_module ( modname ) <EOL> except Exception , e : <EOL> print "<STR_LIT>" % ( modname , e ) <EOL> else : <EOL> mod = sys . modules [ modname ] <EOL> yield modname , mod , ispkg <EOL> else : <EOL> yield packagemod . __name__ , packagemod , False </s>
