From e0ff1581be1015f57a8902527fc8612eaeedd3ff Mon Sep 17 00:00:00 2001 From: anarcat Date: Thu, 2 Mar 2023 23:09:37 -0500 Subject: [PATCH] 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 --- paperbackup.py | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/paperbackup.py b/paperbackup.py index a99fe38..bbb1fa7 100755 --- a/paperbackup.py +++ b/paperbackup.py @@ -184,11 +184,28 @@ def finish_page(pdf, canv, pageno): outlines.append("") outlines.append("sha256sum of input file:") outlines.append("%s"%checksum) -outlines.append("") -outlines.append("") -outlines.append("--") -outlines.append("Created with paperbackup.py") -outlines.append("See https://github.com/intra2net/paperbackup/ for instructions") +outlines += r""" + +-- +Created with paperbackup.py from https://github.com/intra2net/paperbackup/ +To restore, either scan this document into a file or use a webcam +This shell script should restore the content inline + +/usr/bin/zbarimg --raw -Sdisable -Sqrcode.enable "$SCANNEDFILE" \ + | sed -e "s/\^/\x0/g" \ + | sort -z -n \ + | sed ':a;N;$!ba;s/\n\x0[0-9]* //g;s/\x0[0-9]* //g;s/\n\x0//g' + +# replace 'zbarimg \"$SCANNEDFILE\"' with 'zbarcam' if you have a +# webcam instead of a scanned document + +# algorithm: +# 1. zbarimg ends each scanned code with a newline +# 2. each barcode content begins with ^ +# 3. convert that to \0, so sort can sort on that +# 4. then remove all \n\0 so we get the originial without \n + +""".split("\n") # use "enscript" to create postscript with the plaintext p = subprocess.Popen(