Created
January 9, 2015 10:24
-
-
Save Melevir/e177414fc9614abd8b03 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import string | |
import itertools | |
from datetime import datetime | |
import elaphe | |
def create_dirs(): | |
if not os.path.exists('data'): | |
os.mkdir('data') | |
for dir_name in string.ascii_uppercase: | |
full_name = os.path.join('data', dir_name) | |
if not os.path.exists(full_name): | |
os.mkdir(full_name) | |
def create_qr_codes(resize=False): | |
comb = [''.join(a) for a in list(itertools.product(string.ascii_uppercase, repeat=3))] | |
start = datetime.now() | |
for i, c in enumerate(comb): | |
if os.path.exists('%s.jpg' % c): | |
continue | |
# if i > 100: | |
# break | |
if not i % 10: | |
print i, datetime.now() - start | |
pic = elaphe.barcode('qrcode', c, margin=0) | |
if resize: | |
pic = pic.resize((420, 420)) | |
pic.save(os.path.join('data', c[0], '%s.jpg' % c)) | |
print 'fin' | |
create_dirs() | |
create_qr_codes(resize=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment