Skip to content

Commit

Permalink
Add support for stapler (lighter all-python alternative to pdftk)
Browse files Browse the repository at this point in the history
  • Loading branch information
jedbrown committed Jun 7, 2010
1 parent c5912e1 commit a13941e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions springer_download.py
Expand Up @@ -17,8 +17,12 @@ class SpringerURLopener(urllib.FancyURLopener):

# validate CLI arguments and start downloading
def main(argv):
if not findInPath("pdftk"):
error("You have to install pdftk.")
if findInPath("pdftk"):
pdfcat = lambda fileList, bookTitlePath: "pdftk %s cat output '%s'" % (" ".join(fileList), bookTitlePath)
elif findInPath("stapler"):
pdfcat = lambda fileList, bookTitlePath: "stapler cat %s '%s'" % (" ".join(fileList), bookTitlePath)
else:
error("You have to install pdftk (http://www.accesspdf.com/pdftk/) or stapler (http://github.com/hellerbarde/stapler).")
if not findInPath("iconv"):
error("You have to install iconv.")

Expand Down Expand Up @@ -177,7 +181,7 @@ def main(argv):
if len(fileList) == 1:
shutil.move(fileList[0], bookTitlePath)
else:
os.system("pdftk %s cat output '%s'" % (" ".join(fileList), bookTitlePath))
os.system(pdfcat(fileList, bookTitlePath))

# cleanup
os.chdir(curDir)
Expand Down

0 comments on commit a13941e

Please sign in to comment.