Skip to content

Commit e0ff158

Browse files
committed
add actual restore instructions in the document
We use a triple-quoted raw string because there's a lot of escape characters in there. Fixes #16
1 parent 7c3f064 commit e0ff158

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

paperbackup.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,28 @@ def finish_page(pdf, canv, pageno):
184184
outlines.append("")
185185
outlines.append("sha256sum of input file:")
186186
outlines.append("%s"%checksum)
187-
outlines.append("")
188-
outlines.append("")
189-
outlines.append("--")
190-
outlines.append("Created with paperbackup.py")
191-
outlines.append("See https://github.com/intra2net/paperbackup/ for instructions")
187+
outlines += r"""
188+
189+
--
190+
Created with paperbackup.py from https://github.com/intra2net/paperbackup/
191+
To restore, either scan this document into a file or use a webcam
192+
This shell script should restore the content inline
193+
194+
/usr/bin/zbarimg --raw -Sdisable -Sqrcode.enable "$SCANNEDFILE" \
195+
| sed -e "s/\^/\x0/g" \
196+
| sort -z -n \
197+
| sed ':a;N;$!ba;s/\n\x0[0-9]* //g;s/\x0[0-9]* //g;s/\n\x0//g'
198+
199+
# replace 'zbarimg \"$SCANNEDFILE\"' with 'zbarcam' if you have a
200+
# webcam instead of a scanned document
201+
202+
# algorithm:
203+
# 1. zbarimg ends each scanned code with a newline
204+
# 2. each barcode content begins with ^<number><space>
205+
# 3. convert that to \0<number><space>, so sort can sort on that
206+
# 4. then remove all \n\0<number><space> so we get the originial without \n
207+
208+
""".split("\n")
192209

193210
# use "enscript" to create postscript with the plaintext
194211
p = subprocess.Popen(

0 commit comments

Comments
 (0)