-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanonymizer.py
More file actions
65 lines (53 loc) · 2.48 KB
/
anonymizer.py
File metadata and controls
65 lines (53 loc) · 2.48 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python3
# Libraries
from modules import *
from config import configurator
from shutil import copyfile
import argparse
import textwrap
# Arguments parser
parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter,
description=textwrap.dedent('''\
Python Anonymizer - v1.0
-------------------------------------------------------------------------
___ _
/ _ \ (_)
/ /_\ \ _ __ ___ _ __ _ _ _ __ ___ _ ____ ___ _ __
| _ || '_ \ / _ \ | '_ \ | | | || '_ ` _ \ | ||_ / / _ \| '__|
| | | || | | || (_) || | | || |_| || | | | | || | / / | __/| |
\_| |_/|_| |_| \___/ |_| |_| \__, ||_| |_| |_||_|/___| \___||_|
__/ |
|___/
-------------------------------------------------------------------------
'''))
mutually_group = parser.add_mutually_exclusive_group(required=True)
mutually_group.add_argument('-a', '--anonymize', nargs=2, metavar=('FILENAME', 'OUTPUT'), help='\
anonymize data from a CSV file and write the output on another file')
mutually_group.add_argument('-c', '--config', action='store_true', help='\
open a web browser to configure the anonymizer')
mutually_group.add_argument('-s', '--save-config', nargs=1, metavar='FILENAME', help='\
save anonymizer configuration on a json file')
parser.add_argument('-v', '--version', action='version',
version='Python Anonymizer - v1.0')
def main():
args = parser.parse_args()
try:
if args.anonymize != None:
# Anonymize input csv file and export the result
t = Table.Table(args.anonymize[0], args.anonymize[1])
t.start()
print("Your file has been anonymized!")
elif args.config:
# Open web browser to edit the configuration file
print("This feature has not been implemented yet! Sorry")
pass
else:
# Export the configuration file
copyfile('./config/config.json', args.save_config[0])
print("Configuration file has been exported!")
except Exception as e:
print("Fatal error! ", e)
finally:
print("Program terminated! Goodbye.\n")
if __name__ == '__main__':
main()