<s> """<STR_LIT>""" <EOL> import os <EOL> import sys <EOL> import datetime <EOL> import urllib <EOL> import gzip <EOL> def unix_time ( dt ) : <EOL> epoch = datetime . datetime . utcfromtimestamp ( <NUM_LIT:0> ) <EOL> delta = dt - epoch <EOL> return delta . total_seconds ( ) <EOL> def unix_time_millis ( dt ) : <EOL> return unix_time ( dt ) * <NUM_LIT> <EOL> def rreplace ( s , old , new , occurrence ) : <EOL> li = s . rsplit ( old , occurrence ) <EOL> return new . join ( li ) <EOL> files = sys . argv [ <NUM_LIT:1> : ] <EOL> drk_dic = { } <EOL> for f in files : <EOL> src = rreplace ( os . path . basename ( f ) . split ( '<STR_LIT:->' ) [ <NUM_LIT:0> ] , '<STR_LIT:.>' , '<STR_LIT::>' , <NUM_LIT:1> ) <EOL> dst = rreplace ( os . path . basename ( f ) . split ( '<STR_LIT:->' ) [ <NUM_LIT:1> ] , '<STR_LIT:.>' , '<STR_LIT::>' , <NUM_LIT:1> ) <EOL> fd = open ( f , '<STR_LIT:r>' ) <EOL> lines = fd . read ( ) . split ( '<STR_LIT:\n>' ) <EOL> fd . close ( ) <EOL> last_seen_time = <NUM_LIT> <EOL> for line in lines : <EOL> try : <EOL> ts = line [ : <NUM_LIT:15> ] . split ( '<STR_LIT::>' ) <EOL> msg = urllib . quote ( line [ <NUM_LIT:16> : ] ) <EOL> msg = msg . replace ( "<STR_LIT>" , "<STR_LIT:U+0020>" ) <EOL> d = datetime . datetime ( <NUM_LIT> , <NUM_LIT:6> , <NUM_LIT:1> , <EOL> int ( ts [ <NUM_LIT:0> ] ) , <EOL> int ( ts [ <NUM_LIT:1> ] ) , <EOL> int ( ts [ <NUM_LIT:2> ] . split ( '<STR_LIT:.>' ) [ <NUM_LIT:0> ] ) , <EOL> int ( ts [ <NUM_LIT:2> ] . split ( '<STR_LIT:.>' ) [ <NUM_LIT:1> ] ) ) <EOL> d = unix_time_millis ( d ) <EOL> last_seen_time = d <EOL> drk_dic [ d ] = '<STR_LIT:U+0020>' . join ( [ '<STR_LIT:T>' , src , dst , msg ] ) <EOL> except Exception as e : <EOL> print e <EOL> if last_seen_time in drk_dic : <EOL> prev_line = drk_dic [ last_seen_time ] <EOL> drk_dic [ last_seen_time ] = urllib . quote ( '<STR_LIT:\r\n>' ) . join ( [ prev_line , <EOL> msg ] ) <EOL> else : <EOL> drk_dic [ last_seen_time ] = '<STR_LIT:U+0020>' . join ( [ '<STR_LIT:T>' , src , dst , msg ] ) <EOL> fd = gzip . open ( "<STR_LIT>" , "<STR_LIT:w>" ) <EOL> keys = drk_dic . keys ( ) <EOL> keys . sort ( ) <EOL> for k in keys : <EOL> if k == <NUM_LIT:0> : <EOL> timestamp = "<STR_LIT>" <EOL> else : <EOL> timestamp = "<STR_LIT>" % k <EOL> line = "<STR_LIT>" . format ( timestamp , drk_dic [ k ] ) <EOL> fd . write ( line ) <EOL> fd . close ( ) </s>
