aboutsummaryrefslogtreecommitdiff
path: root/worker/worker1.py
blob: 5c474b2e0cb60adf3af67e774b6eaa8aaa9e5f53 (plain) (blame)
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
#!/usr/bin/env python
import os
import argparse

PARSER = argparse.ArgumentParser()
PARSER.add_argument('--output-dir', '-o', default=os.path.abspath(os.curdir))
PARSER.add_argument('INFILE', action='store', nargs='*', help='Input file')
ARGS = PARSER.parse_args()

def do_work(ifile):
    ofile = os.path.join(ARGS.output_dir, os.path.basename(ifile))
    in_data = []
    out_data = []
    
    print('Loading {} ({} bytes)'.format(ifile, os.path.getsize(ifile)))
    
    with open(ifile) as fp:
        for line in fp:
            line = line.rstrip()
            in_data.append(line)
    
    with open(ofile) as fp:
        for value in in_data:
            fp.writeline(value+1)
            
    

if __name__ == '__main__':
        
    for infile in ARGS.INFILE:
        do_work(os.path.abspath(infile))
    else:
        print("No input file(s) received!")
        exit(1)
    
    exit(0)