Mercurial > hg > kdocs
annotate make/splitols.py @ 51:93c68f362860
New script to download OLS files (and others), and split up volumes into
individual papers, plus teach make.sh to run it.
author | Rob Landley <rob@landley.net> |
---|---|
date | Fri, 28 Sep 2007 14:47:14 -0500 |
parents | |
children | d74a0e18965b |
rev | line source |
---|---|
51
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
1 #!/usr/bin/python |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
2 |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
3 # Break up the OLS volumes into individual papers in the ols/$YEAR directories. |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
4 |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
5 # usage: splitols.py mirrordir olsdir |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
6 |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
7 import os, sys |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
8 |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
9 inpath=sys.argv[1] |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
10 outpath=sys.argv[2] |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
11 |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
12 def splitvolume(infile, outpath, credits, numbers): |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
13 for i in xrange(len(numbers)-1): |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
14 next = int(numbers[i+1])-1 |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
15 command="pdftk %s/%s.pdf cat %s-%s 1-1 %s-%s output %s/%s-pages-%s-%s.pdf" % (inpath,infile,numbers[i],next,credits,credits,outpath,infile,numbers[i],next) |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
16 print command |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
17 os.system(command) |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
18 |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
19 volumes = ( ("ols2002", "2002", 7, (8, 31, 40, 50, 55, 65, 73, 93, 107, 117, 130, 146, 176, 183, 191, 197, 213, 223, 242, 250, 260, 265, 274, 289, 301, 310, 317, 330, 338, 368, 376, 383, 390, 407, 414, 425, 439, 451, 459, 468, 479, 496, 521, 530, 545, 556, 565, 573, 594, 604, 618, 632)), |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
20 ("ols2003", "2003", 7, (8, 23, 34, 44, 50, 63, 76, 89, 98, 109, 117, 128, 134, 150, 169, 185, 201, 213, 219, 233, 242, 249, 258, 260, 275, 285, 297, 304, 315, 321, 325, 340, 351, 367, 373, 380, 387, 398, 410, 424, 434, 447, 457, 470, 480, 494, 507, 524, 531)), |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
21 ("ols2004v1", "2004", 7, (9, 23, 33, 41, 51, 63, 79, 89, 103, 113, 121, 133, 149, 163, 167, 187, 203, 207, 215, 227, 239, 255, 269, 287, 295)), |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
22 ("ols2004v2", "2004", 7, (9, 15, 25, 31, 43, 61, 71, 75, 81, 85, 95, 105, 117, 139, 163, 175, 181, 195, 209, 225, 239, 251, 261, 271, 287, 297, 307)), |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
23 ("ols2005v1", "2005", 7, (9, 21, 37, 49, 59, 77, 105, 117, 135, 141, 155, 177, 189, 203, 209, 227, 241, 247, 253, 257, 277, 279, 289, 297, 305, 313, 321, 335, 347)), |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
24 |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
25 ("ols2005v2", "2005", 7, (9, 19, 33, 43, 57, 73, 87, 99, 119, 141, 149, 159, 183, 201, 213, 217, 227, 229, 243, 259, 273, 279, 291, 299, 305, 321)), |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
26 ("ols2006v1", "2006", 7, (9, 19, 27, 39, 57, 71, 87, 101, 113, 127, 147, 153, 177, 193, 209, 225, 235, 247, 261, 269, 289, 303, 313, 333, 347, 369, 385, 395, 409, 421, 427, 441, 451)), |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
27 ("ols2006v2", "2006", 7, (9, 25, 35, 45, 59, 73, 79, 83, 91, 99, 109, 125, 131, 147, 151, 159, 173, 181, 193, 209, 223, 239, 249, 263, 275, 295, 303, 313, 321, 337, 349, 357, 371, 387, 401, 411, 417, 423, 437)), |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
28 ("ols2007v1", "2007", 7, (9, 21, 29, 41, 53, 65, 75, 81, 87, 93, 103, 113, 125, 131, 141, 153, 167, 179, 189, 201, 205, 215, 225, 231, 238, 245, 251, 263, 277, 285, 293, 303, 315)), |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
29 ("ols2007v2", "2007", 7, (9, 21, 35, 45, 59, 65, 71, 79, 87, 97, 107, 119, 127, 135, 145, 151, 161, 173, 179, 187, 201, 209, 223, 229, 235, 245, 253, 261, 273, 285, 297, 305, 311, 319))) |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
30 |
93c68f362860
New script to download OLS files (and others), and split up volumes into
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
31 for i in volumes: splitvolume(i[0],"%s/%s" % (outpath,i[1]),i[2],i[3]) |