<s> """<STR_LIT>""" <EOL> import sys <EOL> import os <EOL> from snakefood . depends import read_depends , eliminate_redundant_depends <EOL> prefix = '''<STR_LIT>''' <EOL> postfix = '''<STR_LIT>''' <EOL> COLORS = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> def graph ( pairs , write , fontsize , color_map ) : <EOL> "<STR_LIT>" <EOL> write ( prefix % fontsize ) <EOL> for ( froot , f ) , ( troot , t ) in pairs : <EOL> if opts . pythonify_filenames : <EOL> f = normpyfn ( f ) <EOL> t = normpyfn ( t ) <EOL> if opts . full_pathnames : <EOL> f = os . path . join ( froot , f ) <EOL> if troot : <EOL> t = os . path . join ( troot , t ) <EOL> if troot is None : <EOL> dn = os . path . dirname ( f ) <EOL> if dn not in color_map : <EOL> color_map [ dn ] = COLORS [ len ( color_map ) % len ( COLORS ) ] <EOL> write ( '<STR_LIT>' % ( f , color_map [ dn ] ) ) <EOL> else : <EOL> write ( '<STR_LIT>' % ( f , t ) ) <EOL> write ( postfix ) <EOL> def normpyfn ( fn ) : <EOL> "<STR_LIT>" <EOL> if fn is None : <EOL> return fn <EOL> if fn . endswith ( '<STR_LIT>' ) : <EOL> fn = fn [ : - <NUM_LIT:3> ] <EOL> fn = fn . replace ( os . sep , '<STR_LIT:.>' ) <EOL> return fn <EOL> def main ( ) : <EOL> import optparse <EOL> parser = optparse . OptionParser ( __doc__ . strip ( ) ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:store_true>' , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> action = '<STR_LIT:store_true>' , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT>' , default = True , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_option ( '<STR_LIT>' , action = '<STR_LIT:store>' , type = '<STR_LIT:int>' , <EOL> default = <NUM_LIT:10> , <EOL> help = "<STR_LIT>" ) <EOL> global opts <EOL> opts , args = parser . parse_args ( ) <EOL> if not args : <EOL> args = [ '<STR_LIT:->' ] <EOL> color_map = { } <EOL> for fn in args : <EOL> if fn == '<STR_LIT:->' : <EOL> f = sys . stdin <EOL> else : <EOL> f = open ( fn ) <EOL> depends = read_depends ( f ) <EOL> if opts . redundant : <EOL> depends = eliminate_redundant_depends ( depends ) <EOL> graph ( depends , sys . stdout . write , opts . fontsize , color_map ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( ) </s>
