-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_parse.py
More file actions
47 lines (39 loc) · 2.32 KB
/
make_parse.py
File metadata and controls
47 lines (39 loc) · 2.32 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
import argparse
import crypt
class Parse:
def __init__(self):
self.parser = argparse.ArgumentParser()
subparsers = self.parser.add_subparsers(dest='command')
parser_e = subparsers.add_parser('encode')
parser_e.add_argument('--cipher', required=True, default=None,
help='Choose cipher')
parser_e.add_argument('--key', required=True, default=None, help='key')
parser_e.add_argument('--input-file', default=None, help='input file')
parser_e.add_argument('--output-file', default=None, help='output file')
parser_d = subparsers.add_parser('decode')
parser_d.add_argument('--cipher', required=True, default=None,
help='Choose cipher')
parser_d.add_argument('--key', required=True, default=None, help='key')
parser_d.add_argument('--input-file', default=None, help='input file')
parser_d.add_argument('--output-file', default=None, help='output file')
parser_a = subparsers.add_parser('analyse')
parser_a.add_argument('--input-file', default=None, help='input file')
parser_a.add_argument('--output-file', default=None, help='output file')
self.args = self.parser.parse_args()
def print_parse(self):
if self.args.command == 'encode':
if self.args.cipher == 'caesar':
crypt.caesar_encode(self.args.input_file, self.args.output_file, int(self.args.key))
elif self.args.cipher == 'vigenere':
crypt.vigenere_encode(self.args.input_file, self.args.output_file, self.args.key)
elif self.args.cipher == 'vernam':
crypt.vernam_encode(self.args.input_file, self.args.output_file, self.args.key)
elif self.args.command == 'decode':
if self.args.cipher == 'caesar':
crypt.caesar_decode(self.args.input_file, self.args.output_file, int(self.args.key))
elif self.args.cipher == 'vigenere':
crypt.vigenere_decode(self.args.input_file, self.args.output_file, self.args.key)
elif self.args.cipher == 'vernam':
crypt.vernam_decode(self.args.input_file, self.args.output_file, self.args.key)
elif self.args.command == 'analyse':
crypt.analyses(self.args.input_file, self.args.output_file)