-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathM3_OoiKherNing_1191100876_MODIFIED.py
72 lines (63 loc) · 2.85 KB
/
M3_OoiKherNing_1191100876_MODIFIED.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#*****************************************************#
#File Name: M3_OoiKherNing_1191100876_MODIFIED.py
#Version/Date: FINAL (2020-06-02)
#Programmer/ID: Ooi Kher Ning 1191100876
#Project Name: Random Password Generator
#Teammates: Teh Su Anne, Chin Pei Wern, Leong Xin-Nan
#Course/Term: PSP0201 Mini IT Project (2019/20 T3)
#*****************************************************#
import pip_install
import pyqrcode
import barcode
from barcode.writer import ImageWriter
import os
choicelist = ['q', 'b']
confirmlist = ['y', 'n']
#function of checking whether the name of the png file used or not
def duplicatePNG_checker(pngname):
filename = []
file_path = os.path.dirname(__file__)
for root, dirs, files in os.walk (file_path):
for file in files:
if file.endswith('.png'):
filename.append(file)
if pngname in filename:
return True
elif len(pngname.strip())<1:
return True
else:
return False
#-------------------------------------------- qrcode ------------------------------------------------#
def qrcode(choose_category,qrcode_option2,data,qname):
if choose_category == 'social media':
choose_category = "Social Media"
data = 'Category : ' + choose_category + '\n' + 'Subject : ' + qrcode_option2 + '\n' + 'Notes : ' + data
q = pyqrcode.create(data)
q.png('./QRcode/'+qname, scale=7)
elif choose_category == 'entertainment':
choose_category = "Entertainment"
data = 'Category : ' + choose_category + '\n' + 'Subject : ' + qrcode_option2 + '\n' + 'Notes : ' + data
q = pyqrcode.create(data)
q.png('./QRcode/'+qname, scale=7)
elif choose_category == 'work':
choose_category = "Work"
data = 'Category :' + choose_category + '\n' + 'Subject : ' + qrcode_option2 + '\n' + 'Notes : ' + data
q = pyqrcode.create(data)
q.png('./QRcode/'+qname, scale=7)
elif choose_category == 'study':
choose_category = "Study"
data = 'Category : ' + choose_category + '\n' + 'Subject : ' + qrcode_option2 + '\n' + 'Notes : ' + data
q = pyqrcode.create(data)
q.png('./QRcode/'+qname, scale=7)
else:
data = 'Category : ' + choose_category + '\n' + 'Subject : ' + str(qrcode_option2) + '\n' + 'Notes : ' + data
q = pyqrcode.create(data)
q.png('./QRcode/'+qname, scale=7)
#----------------------------------------------------barcode--------------------------------------------------#
#barcode writer
writer = barcode.get_barcode_class('code128')
writer.default_writer_options['write_text'] = False
def barcode(data,bname):
data ='Notes : ' + data
b = writer(data, writer=ImageWriter())
c = b.save('./BARcode/'+bname)