<s> from deepnet import util <EOL> from deepnet import deepnet_pb2 <EOL> import sys , os <EOL> from google . protobuf import text_format <EOL> proto1 = sys . argv [ <NUM_LIT:1> ] <EOL> proto2 = sys . argv [ <NUM_LIT:2> ] <EOL> output_pbtxt = sys . argv [ <NUM_LIT:3> ] <EOL> out_dir = '<STR_LIT:/>' . join ( output_pbtxt . split ( '<STR_LIT:/>' ) [ : - <NUM_LIT:1> ] ) <EOL> if out_dir and not os . path . isdir ( out_dir ) : <EOL> os . makedirs ( out_dir ) <EOL> dataset1 = util . ReadData ( proto1 ) <EOL> name1 = dataset1 . name <EOL> dataset2 = util . ReadData ( proto2 ) <EOL> name2 = dataset2 . name <EOL> dataset1_prefix = dataset1 . prefix <EOL> dataset2_prefix = dataset2 . prefix <EOL> prefix = os . path . commonprefix ( [ dataset1_prefix , dataset2_prefix ] ) <EOL> if dataset1_prefix != dataset2_prefix : <EOL> for dataset in [ dataset1 , dataset2 ] : <EOL> _prefix = dataset . prefix [ len ( prefix ) : ] <EOL> for d in dataset . data : <EOL> if d . file_pattern : <EOL> d . file_pattern = os . path . join ( _prefix , d . file_pattern ) <EOL> if d . stats_file : <EOL> d . file_pattern = os . path . join ( _prefix , d . stats_file ) <EOL> dataset1 . MergeFrom ( dataset2 ) <EOL> dataset1 . name = '<STR_LIT>' % ( name1 , name2 ) <EOL> dataset1 . prefix = prefix <EOL> with open ( output_pbtxt , '<STR_LIT:w>' ) as f : <EOL> text_format . PrintMessage ( dataset1 , f ) </s>
