<s> """<STR_LIT>""" <EOL> import os . path <EOL> import re <EOL> import git <EOL> import managers <EOL> import util <EOL> def walk ( b , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> walk_sources ( b , ** kwargs ) <EOL> walk_files ( b , ** kwargs ) <EOL> walk_packages ( b , ** kwargs ) <EOL> walk_services ( b , ** kwargs ) <EOL> def walk_sources ( b , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> kwargs . get ( '<STR_LIT>' , lambda * args : None ) ( ) <EOL> pattern = re . compile ( r'<STR_LIT>' , re . I ) <EOL> callable = kwargs . get ( '<STR_LIT:source>' , lambda * args : None ) <EOL> for dirname , filename in sorted ( b . get ( '<STR_LIT>' , { } ) . iteritems ( ) ) : <EOL> if pattern . match ( filename ) is None : <EOL> def gen_content ( ) : <EOL> tree = git . tree ( b . _commit ) <EOL> blob = git . blob ( tree , filename ) <EOL> return git . content ( blob ) <EOL> callable ( dirname , filename , gen_content , None ) <EOL> else : <EOL> url = filename <EOL> filename = os . path . basename ( url ) <EOL> if '<STR_LIT>' == filename : <EOL> filename = '<STR_LIT>' <EOL> callable ( dirname , filename , None , url ) <EOL> kwargs . get ( '<STR_LIT>' , lambda * args : None ) ( ) <EOL> def walk_files ( b , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> kwargs . get ( '<STR_LIT>' , lambda * args : None ) ( ) <EOL> callable = kwargs . get ( '<STR_LIT:file>' , lambda * args : None ) <EOL> for pathname , f in sorted ( b . get ( '<STR_LIT>' , { } ) . iteritems ( ) ) : <EOL> if '<STR_LIT:content>' in f and not isinstance ( f [ '<STR_LIT:content>' ] , basestring ) : <EOL> f [ '<STR_LIT:content>' ] = util . json_dumps ( f [ '<STR_LIT:content>' ] ) <EOL> callable ( pathname , f ) <EOL> kwargs . get ( '<STR_LIT>' , lambda * args : None ) ( ) <EOL> def walk_packages ( b , managername = None , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if managername is None : <EOL> walk_packages ( b , '<STR_LIT>' , ** kwargs ) <EOL> walk_packages ( b , '<STR_LIT>' , ** kwargs ) <EOL> walk_packages ( b , '<STR_LIT>' , ** kwargs ) <EOL> return <EOL> manager = managers . PackageManager ( managername ) <EOL> kwargs . get ( '<STR_LIT>' , lambda * args : None ) ( manager ) <EOL> next_managers = [ ] <EOL> callable = kwargs . get ( '<STR_LIT>' , lambda * args : None ) <EOL> for package , versions in sorted ( b . get ( '<STR_LIT>' , <EOL> { } ) . get ( manager , <EOL> { } ) . iteritems ( ) ) : <EOL> if <NUM_LIT:0> == len ( versions ) : <EOL> callable ( manager , package , None ) <EOL> elif isinstance ( versions , basestring ) : <EOL> callable ( manager , package , versions ) <EOL> else : <EOL> for version in versions : <EOL> callable ( manager , package , version ) <EOL> if managername != package and package in b . get ( '<STR_LIT>' , { } ) : <EOL> next_managers . append ( package ) <EOL> kwargs . get ( '<STR_LIT>' , lambda * args : None ) ( manager ) <EOL> for managername in next_managers : <EOL> walk_packages ( b , managername , ** kwargs ) <EOL> def walk_services ( b , managername = None , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if managername is None : <EOL> for managername in sorted ( b . get ( '<STR_LIT>' , { } ) . iterkeys ( ) ) : <EOL> walk_services ( b , managername , ** kwargs ) <EOL> return <EOL> manager = managers . ServiceManager ( managername ) <EOL> kwargs . get ( '<STR_LIT>' , lambda * args : None ) ( manager ) <EOL> callable = kwargs . get ( '<STR_LIT>' , lambda * args : None ) <EOL> for service , deps in sorted ( b . get ( '<STR_LIT>' , <EOL> { } ) . get ( manager , <EOL> { } ) . iteritems ( ) ) : <EOL> callable ( manager , service ) <EOL> walk_service_files ( b , manager , service , ** kwargs ) <EOL> walk_service_packages ( b , manager , service , ** kwargs ) <EOL> walk_service_sources ( b , manager , service , ** kwargs ) <EOL> kwargs . get ( '<STR_LIT>' , lambda * args : None ) ( manager ) <EOL> def walk_service_files ( b , manager , servicename , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> deps = b . get ( '<STR_LIT>' , { } ) . get ( manager , { } ) . get ( servicename , { } ) <EOL> if '<STR_LIT>' not in deps : <EOL> return <EOL> callable = kwargs . get ( '<STR_LIT>' , lambda * args : None ) <EOL> for pathname in list ( deps [ '<STR_LIT>' ] ) : <EOL> callable ( manager , servicename , pathname ) <EOL> def walk_service_packages ( b , manager , servicename , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> deps = b . get ( '<STR_LIT>' , { } ) . get ( manager , { } ) . get ( servicename , { } ) <EOL> if '<STR_LIT>' not in deps : <EOL> return <EOL> callable = kwargs . get ( '<STR_LIT>' , lambda * args : None ) <EOL> for package_managername , packages in deps [ '<STR_LIT>' ] . iteritems ( ) : <EOL> for package in packages : <EOL> callable ( manager , servicename , package_managername , package ) <EOL> def walk_service_sources ( b , manager , servicename , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> deps = b . get ( '<STR_LIT>' , { } ) . get ( manager , { } ) . get ( servicename , { } ) <EOL> if '<STR_LIT>' not in deps : <EOL> return <EOL> callable = kwargs . get ( '<STR_LIT>' , lambda * args : None ) <EOL> for dirname in list ( deps [ '<STR_LIT>' ] ) : <EOL> callable ( manager , servicename , dirname ) </s>
