view 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
line wrap: on
line source

#!/usr/bin/python

# Break up the OLS volumes into individual papers in the ols/$YEAR directories.

# usage: splitols.py mirrordir olsdir

import os, sys

inpath=sys.argv[1]
outpath=sys.argv[2]

def splitvolume(infile, outpath, credits, numbers):
  for i in xrange(len(numbers)-1):
    next = int(numbers[i+1])-1
    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)
    print command
    os.system(command)

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)),
            ("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)),
            ("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)),
            ("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)),
            ("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)),

            ("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)),
            ("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)),
            ("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)),
            ("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)),
            ("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)))

for i in volumes: splitvolume(i[0],"%s/%s" % (outpath,i[1]),i[2],i[3])