2 # -*- coding: utf-8 -*-
3 # Debian-Depends: poppler-utils (pdftotext)
5 from subprocess import Popen, PIPE
10 for filename in sys.argv[1:]:
12 os.chdir(os.path.dirname(filename))
13 filename = os.path.basename(filename)
14 p1 = Popen(["/usr/bin/pdftotext", filename, "-"], stdout=PIPE)
15 p2 = Popen(["/bin/sed", "-e", "s|\t\r | |g;s|-‐|–|g;s| \+| |g"], stdin=p1.stdout, stdout=PIPE)
16 p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits.
17 output = p2.communicate()[0]
18 file(filename + '.txt', 'wt').write(output)