-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer_merge.py
47 lines (30 loc) · 1.31 KB
/
player_merge.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import argparse
class PlayerMerger(object):
def __init__(self, files_to_merge, outfile):
self._input_files = files_to_merge
self._output_file = outfile
def merge(self):
with open(self._output_file, "w") as fo:
pass
def get_command_line_args():
"""Set up the CLI arguments and return the values"""
parser = argparse.ArgumentParser(
description='Merge multiple player databases together')
parser.add_argument('files', metavar='files', nargs='+',
help='a list of player databases to merge')
parser.add_argument('-o', dest='outfile', default='outfile.csv',
help='the destination file for the merged database')
return parser.parse_args()
def get_input_files(*args):
"""Return a list of the inputted file names with their weights"""
# check if arg list is even and every other arg is an integer
if len(args) % 2 == 0 and all(x.isdigit() for x in args[1::2]):
# return the args, all tupled up
return zip(args[::2], args[1::2])
else:
# return each arg with a weight of 1
return [(x, 1) for x in args]
if __name__ == '__main__':
cli_args = get_command_line_args()
merger = PlayerMerger(get_input_files(*cli_args.files), cli_args.outfile)
merger.merge()