File tree 3 files changed +44
-1
lines changed 3 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -5,5 +5,5 @@ pycodestyle
5
5
pylint
6
6
pylint-quotes
7
7
pytest
8
- pytype
8
+ pytype == 2020.2.20
9
9
semver
Original file line number Diff line number Diff line change 1
1
requests
2
+ qrcode
Original file line number Diff line number Diff line change
1
+ import qrcode
2
+ import platform
3
+
4
+
5
+ def qr_terminal_str (data ,version = None ):
6
+ """
7
+
8
+ :param data: qrcode data
9
+ :param version:1-40 or None
10
+ :return:
11
+ """
12
+ if platform .system () == "Windows" :
13
+ white_block = '▇'
14
+ black_block = ' '
15
+ new_line = '\n '
16
+ else :
17
+ white_block = '\033 [0;37;47m '
18
+ black_block = '\033 [0;37;40m '
19
+ new_line = '\033 [0m\n '
20
+
21
+ qr = qrcode .QRCode (version )
22
+ qr .add_data (data )
23
+ if version :
24
+ qr .make ()
25
+ else :
26
+ qr .make (fit = True )
27
+ output = white_block * (qr .modules_count + 2 ) + new_line
28
+ for mn in qr .modules :
29
+ output += white_block
30
+ for m in mn :
31
+ if m :
32
+ output += black_block
33
+ else :
34
+ output += white_block
35
+ output += white_block + new_line
36
+ output += white_block * (qr .modules_count + 2 ) + new_line
37
+ return output
38
+
39
+
40
+ def draw (data , version = None ):
41
+ output = qr_terminal_str (data ,version )
42
+ print (output )
You can’t perform that action at this time.
0 commit comments