Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

small changes

  • Loading branch information...
commit 5e0ac9fbbba3113262133e821ce51dea0de938d4 1 parent f48b414
Jabba Laci authored
View
3  .gitignore
@@ -0,0 +1,3 @@
+!.gitignore
+gimp/
+python/
View
20 02-extract.py
@@ -2,14 +2,26 @@
import os
import sys
+import errno
# extract.py
-if len(sys.argv) == 1:
- print "Usage: %s series.csv" % sys.argv[0]
+# one parameter is required and that parameter must be a .csv file
+if (len(sys.argv) == 1) or (os.path.splitext(sys.argv[1])[1] != '.csv'):
+ print "Usage: {prg} series.csv".format(prg=sys.argv[0])
+ print "Tip: the passed parameter file must have .csv extension."
sys.exit()
-# else, if a parameter was passed
+# else, if a .csv file was passed
+
+topic = os.path.splitext(sys.argv[1])[0] # ex. gimp.csv => gimp
+
+try:
+ os.makedirs("{topic}/result".format(topic=topic))
+except OSError as exc:
+ if exc.errno == errno.EEXIST:
+ pass
+ else: raise
f1 = open(sys.argv[1], 'r')
@@ -19,7 +31,7 @@
# else
line = line.rstrip('\n')
(issue, start_page, end_page) = line.split(';')
- command = "pdftk issues/issue%s_en.pdf cat %s-%s output pieces/%s-%s.pdf" % (issue, start_page, end_page, issue, os.path.splitext(sys.argv[1])[0] )
+ command = "pdftk issues/issue{n}_en.pdf cat {start}-{end} output {topic}/{issue}-{topic}.pdf".format(n=issue, start=start_page, end=end_page, issue=issue, topic=topic)
print command
os.system(command)
View
28 03-combine-pieces.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+
+import os
+import sys
+
+# combine.py
+
+# one parameter is required and that parameter must be a .csv file
+if (len(sys.argv) == 1) or (os.path.splitext(sys.argv[1])[1] != '.csv'):
+ print "Usage: {prg} series.csv".format(prg=sys.argv[0])
+ print "Tip: the passed parameter file must have .csv extension."
+ sys.exit()
+
+# else, if a .csv file was passed
+
+topic = os.path.splitext(sys.argv[1])[0] # ex. gimp.csv => gimp
+
+dest = "{topic}/result".format(topic=topic)
+if not os.path.exists(dest):
+ print "Error: {dest} doesn't exist.".format(dest=dest)
+ print "Tip: did you execute the 2nd script?"
+ sys.exit()
+
+# else, if the destination directory is there
+
+command = "pdftk {topic}/*.pdf cat output {topic}/result/all.pdf".format(topic=topic)
+print command
+os.system(command)
View
3  03-combine-pieces.sh
@@ -1,3 +0,0 @@
-#!/usr/bin/env bash
-
-pdftk pieces/*.pdf cat output result/all.pdf
View
6 README
@@ -2,7 +2,7 @@ Full-Circle-Magazine-Series
===========================
Author: Laszlo Szathmary (jabba.laci@gmail.com)
-Last update: 2011-08-27 (yyyy-mm-dd)
+Last update: 2012-01-08 (yyyy-mm-dd)
Version: 0.2
Home page: https://ubuntuincident.wordpress.com/2011/02/21/python-tutorials-of-full-circle-magazine-in-a-single-pdf/
@@ -27,8 +27,8 @@ Usage:
You can write your own series.csv file (ex.: gimp.csv) to extract
a different series.
-./03-combine-pieces.sh
+./03-combine-pieces.py python.csv
Combine the pieces together in a single PDF. Location of the result:
- result/all.pdf.
+ python/result/all.pdf.
If you combine the pieces with Adobe Acrobat Pro, the size of the
resulting file will be very small. Pdftk produces a much larger file.
View
1  issues.txt
@@ -54,3 +54,4 @@ http://dl.fullcirclemagazine.org/issue52_en.pdf
http://dl.fullcirclemagazine.org/issue53_en.pdf
http://dl.fullcirclemagazine.org/issue54_en.pdf
http://dl.fullcirclemagazine.org/issue55_en.pdf
+http://dl.fullcirclemagazine.org/issue56_en.pdf
View
2  pieces/.gitignore
@@ -1,2 +0,0 @@
-*
-!.gitignore
View
2  result/.gitignore
@@ -1,2 +0,0 @@
-*
-!.gitignore
Please sign in to comment.
Something went wrong with that request. Please try again.