def main(): if not AVAILABLE_FORMATS: print 'error: no output format module is available.' sys.exit(1) parser = make_parser() (options, args) = parser.parse_args() if len(args) < 1: parser.error('no replay file specified.') elif len(args) > 1: parser.error('only one replay file may be dumped at a time.') rep = replay.Replay(args[0]) if options.format == 'json': dump_json(rep) elif options.format == 'yaml': dump_yaml(rep) elif options.format == 'xml': dump_xml(rep)
def move_if_needed(prefix): """ Goes through all replays in "prefix" and moves them to the right match-up folders (based on the "match_up" heuristic) """ print 'working on', prefix for dname in os.listdir(prefix): if os.path.isdir(prefix+dname): print dname for fname in os.listdir(prefix+dname): if fname[-3:] == 'rep': fullfn = prefix + dname + '/' + fname print fullfn try: rep = replay.Replay(fullfn) mu = match_up(rep) if dname != mu: shutil.move(fullfn, prefix + mu + '/' + fname) print 'moved:', fullfn print 'to:', prefix+mu+'/'+fname except replay.InvalidReplayException: print 'removing', fullfn shutil.move(fullfn, prefix + 'trash/' + fname)
from pyreplib import replay import sys for arg in sys.argv[1:]: try: replay.Replay(arg) except: print arg, ": bad replay"
""" Goes through all replays in "prefix" and moves them to the right match-up folders (based on the "match_up" heuristic) """ print 'working on', prefix for dname in os.listdir(prefix): if os.path.isdir(prefix+dname): print dname for fname in os.listdir(prefix+dname): if fname[-3:] == 'rep': fullfn = prefix + dname + '/' + fname print fullfn try: rep = replay.Replay(fullfn) mu = match_up(rep) if dname != mu: shutil.move(fullfn, prefix + mu + '/' + fname) print 'moved:', fullfn print 'to:', prefix+mu+'/'+fname except replay.InvalidReplayException: print 'removing', fullfn shutil.move(fullfn, prefix + 'trash/' + fname) if __name__ == '__main__': if len(sys.argv) < 2: print "need an arg" else: if (sys.argv[len(sys.argv)-1][-3:] == 'rep'): print match_up(replay.Replay(sys.argv[len(sys.argv)-1])) else: move_if_needed(sys.argv[len(sys.argv)-1])