From 88c0004484f6370d74eba9c1bff1c9062fe5d0a0 Mon Sep 17 00:00:00 2001 From: Justin Calamari Date: Fri, 20 Apr 2018 16:51:31 -0400 Subject: [PATCH 1/3] Change qr template --- sampledb/generate_qr.py | 16 +++++++++++++--- sampledb/templates/qr_template.tex | 8 ++++---- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/sampledb/generate_qr.py b/sampledb/generate_qr.py index bea05a4..785cfe6 100644 --- a/sampledb/generate_qr.py +++ b/sampledb/generate_qr.py @@ -3,6 +3,7 @@ import qrcode import uuid import subprocess +import numpy as np from glob import glob LATEX_OPTS = ['-halt-on-error', '-file-line-error'] @@ -26,6 +27,7 @@ base = 'test' +pages = 1 cols = 3 rows = 10 lmar = 0.1875 @@ -60,15 +62,23 @@ options['gpath'] = base codes = [] -for i in range(rows): +for i in range(pages * rows * cols): uid = str(uuid.uuid4()) code = qrcode.make(uid) filename = uid + '.png' with open(os.path.join(base, filename), 'wb') as img: code.save(img, 'PNG') codes.append((filename, uid[:6])) -options['qrs'] = codes - +codes = [c for c in zip(codes[0::3], codes[1::3], codes[2::3])] +qrs = [] +for c1, c2, c3 in zip(codes[0::3], codes[1::3], codes[2::3]): + for i in range(3): + for c in [c1, c2, c3]: + qrs.append(c) + +options['qrs'] = qrs +#options['qrs'] = [c for c in zip(codes[0::3], codes[1::3], codes[2::3])] +#options['qrs'] = list(itertools.chain.from_iterable(itertools.repeat(x, 3) for x in options['qrs'])) result = template.render(**options) os.makedirs(base, exist_ok=True) diff --git a/sampledb/templates/qr_template.tex b/sampledb/templates/qr_template.tex index 41268b0..d97f51c 100644 --- a/sampledb/templates/qr_template.tex +++ b/sampledb/templates/qr_template.tex @@ -22,10 +22,10 @@ \numberoflabels=1 \begin{document} \begin{labels} -\BLOCK{for qr, uid in qrs} - \hfill\includegraphics[width=\VAR{width}, height=\VAR{height}, keepaspectratio]{\VAR{qr}}\hfill\includegraphics[width=\VAR{width}, height=\VAR{height}, keepaspectratio]{\VAR{qr}}\hfill\includegraphics[width=\VAR{width}, height=\VAR{height}, keepaspectratio]{\VAR{qr}}\hfill\\ - \captionof*{figure}{\hfill \VAR{uid} \hfill \VAR{uid} \hfill \VAR{uid} \hfill} +\BLOCK{for qr1, qr2, qr3 in qrs} + \hfill\includegraphics[width=\VAR{width}, height=\VAR{height}, keepaspectratio]{\VAR{qr1[0]}}\hfill\includegraphics[width=\VAR{width}, height=\VAR{height}, keepaspectratio]{\VAR{qr2[0]}}\hfill\includegraphics[width=\VAR{width}, height=\VAR{height}, keepaspectratio]{\VAR{qr3[0]}}\hfill\\ + \captionof*{figure}{\hfill \VAR{qr1[1]} \hfill \VAR{qr2[1]} \hfill \VAR{qr3[1]} \hfill} \BLOCK{endfor} \end{labels} -\end{document} \ No newline at end of file +\end{document} From 3eea56493ffa960784ae88bd5b4652178a20a253 Mon Sep 17 00:00:00 2001 From: Justin Calamari Date: Fri, 20 Apr 2018 16:53:19 -0400 Subject: [PATCH 2/3] remove unused import --- sampledb/generate_qr.py | 1 - 1 file changed, 1 deletion(-) diff --git a/sampledb/generate_qr.py b/sampledb/generate_qr.py index 785cfe6..5fb64a9 100644 --- a/sampledb/generate_qr.py +++ b/sampledb/generate_qr.py @@ -3,7 +3,6 @@ import qrcode import uuid import subprocess -import numpy as np from glob import glob LATEX_OPTS = ['-halt-on-error', '-file-line-error'] From c538c8bbf958c0601b50ff602008f51b863c2fc5 Mon Sep 17 00:00:00 2001 From: Justin Calamari Date: Fri, 20 Apr 2018 20:33:55 -0400 Subject: [PATCH 3/3] remove commented lines --- sampledb/generate_qr.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/sampledb/generate_qr.py b/sampledb/generate_qr.py index 5fb64a9..1befd00 100644 --- a/sampledb/generate_qr.py +++ b/sampledb/generate_qr.py @@ -76,8 +76,6 @@ qrs.append(c) options['qrs'] = qrs -#options['qrs'] = [c for c in zip(codes[0::3], codes[1::3], codes[2::3])] -#options['qrs'] = list(itertools.chain.from_iterable(itertools.repeat(x, 3) for x in options['qrs'])) result = template.render(**options) os.makedirs(base, exist_ok=True)