Ejemplo n.º 1
0
def process_target(pulldir, stype, bbl):
    subdir = bbl2dirpath(bbl)
    fname = "%s-%d.pdf" % (stype, bbl)
    infile = "%s/%s/%s" % (pulldir, subdir, fname)
    # log.info("infile = %s" % infile)
    with open(infile, "rb") as f:
        for line in textify(f):
            print(line)
Ejemplo n.º 2
0
def process_target(pulldir, stype, bbl):
    subdir = bbl2dirpath(bbl)
    fname = "%s-%d.pdf" % (stype, bbl)
    infile = "%s/%s/%s" % (pulldir, subdir, fname)
    log.info("infile = %s" % infile)
    if os.path.exists(infile):
        with open(infile, "rb") as f:
            return parse(f)
    else:
        return None
Ejemplo n.º 3
0
def rename_target(pulldir, stype, bbl):
    c = Counter()
    subdir = bbl2dirpath(bbl)
    pathbase = "%s/%s/%s-%d" % (pulldir, subdir, stype, bbl)
    oldpath = "%s.pdf" % pathbase
    newpath = "%s.html" % pathbase
    if os.path.exists(oldpath):
        log.info("MOVE oldpath = %s" % oldpath)
        os.rename(oldpath, newpath)
        c['move'] += 1
    else:
        log.info("SKIP oldpath = %s" % oldpath)
        c['skip'] += 1
    return c
Ejemplo n.º 4
0
def purge_target(pulldir, stype, bbl):
    c = Counter()
    subdir = bbl2dirpath(bbl)
    pathbase = "%s/%s/%s-%d" % (pulldir, subdir, stype, bbl)
    checkpath = "%s.html" % pathbase
    if os.path.exists(checkpath):
        badpath = "%s.txt" % pathbase
        if os.path.exists(badpath):
            os.remove(badpath)
            log.info("KILL badpath = %s" % badpath)
            c['kill'] += 1
        else:
            log.info("SKIP badpath = %s" % badpath)
            c['skip-txt'] += 1
    else:
        log.info("SKIP checkpath = %s" % checkpath)
        c['skip-html'] += 1
    return c
Ejemplo n.º 5
0
def make_path(stype, bbl, ext):
    subdir = bbl2dirpath(bbl)
    fname = "%s-%d.%s" % (stype, bbl, ext)
    return "%s/%s" % (subdir, fname)