Skip to content

Commit b0e6ee4

Browse files
committed
bring back input file modification date in the plain text header
1 parent e75ad10 commit b0e6ee4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

paperbackup.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import subprocess
3434
import qrencode
3535
from tempfile import mkstemp
36+
from datetime import datetime
3637
from PIL import Image
3738
from pyx import *
3839

@@ -135,14 +136,16 @@ def finish_page(pdf, canv, pageno):
135136
# will use pdf as the tmpfile has a .pdf suffix
136137
pdf.writetofile(temp_barcode_path)
137138

139+
# prepare plain text output
138140
fd, temp_text_path = mkstemp('.ps', 'text_', '.')
141+
input_file_modification = datetime.fromtimestamp(os.path.getmtime(input_path)).strftime("%Y-%m-%d %H:%M:%S")
139142

140143
# use "enscript" to create postscript with the plaintext
141144
p = subprocess.Popen(
142145
["enscript", "-p"+temp_text_path, "-f", "Courier12",
143-
"-M" + paperformat_str, "--header",
144-
just_filename + "|Page $%"],
145-
stdout=subprocess.PIPE,stdin=subprocess.PIPE)
146+
"-M" + paperformat_str, "--header",
147+
just_filename + "|" + input_file_modification + "|Page $%"],
148+
stdout=subprocess.PIPE, stdin=subprocess.PIPE)
146149

147150
# send the file and a tag line to enscript
148151
p.stdin.write(ascdata.encode('utf-8'))

0 commit comments

Comments
 (0)