-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
executable file
·53 lines (45 loc) · 1.21 KB
/
main.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
48
49
50
51
52
53
#!/usr/bin/python
#-*- coding:utf-8 -*-
# Invoke the QR code generator
import getopt
import sys
from qr_code import QR_Code
def main():
data = ''
err_corc_level = ''
mode = 'Alphanumeric'
version = 2
show = True
save = False
path = ''
size = 5
try:
opts, args = getopt.getopt(
sys.argv[1:], "hd:e:s:", ["notshow", "size="])
for opt, arg in opts:
if opt == '-h':
usage()
sys.exit(1)
if opt == '-d':
data = arg
if opt == '-e':
err_corc_level = arg
if opt == '--notshow':
show = False
if opt == '-s':
path = arg
if opt == '--size':
size = int(arg)
except getopt.GetoptError:
usage()
sys.exit(1)
if data == '' or err_corc_level == '':
usage()
sys.exit(1)
qr_code = QR_Code(data, mode, version, err_corc_level)
qr_code.draw(show=show, save=save, path=path, figsize=size)
def usage():
print "Usage: %s -d <data> -e <level> [-s <path>] [-h] " % sys.argv[0],\
"[--notshow] [--size <size>]"
if __name__ == '__main__':
main()