Example #1
0
def get_shelf_path(xd, pubid, mdtext):
    publisher = ""
    if not pubid:
        pubid = find_pubid(mdtext)

    if pubid:
        publ = metadb.xd_publications()[pubid]
    else:
        publ = get_publication(xd)
        if publ:
            pubid = publ.PublicationAbbr
        else:
            return None

    if not pubid:
        utils.warn("unknown pubid for '%s'" % xd.filename)
        return None

    publisher = publ.PublisherAbbr

    num = xd.get_header('Number')
    if num:
        return "%s/%s-%03d" % (publisher or pubid, pubid, int(num))

    dt = xd.get_header("Date")
    if not dt:
        utils.warn("neither Number nor Date for '%s'" % xd.filename)
        return 'misc/' + xd.filename

    year = xdfile.year_from_date(dt)
    return "%s/%s/%s%s" % (publisher, year, pubid, dt)
Example #2
0
def get_shelf_path(xd, pubid, mdtext):
    publisher = ""
    if not pubid:
        pubid = find_pubid(mdtext)

    if pubid:
        publ = metadb.xd_publications()[pubid]
    else:
        publ = get_publication(xd)
        if publ:
            pubid = publ.PublicationAbbr
        else:
            return None

    if not pubid:
        utils.warn("unknown pubid for '%s'" % xd.filename)
        return None

    publisher = publ.PublisherAbbr

    num = xd.get_header('Number')
    if num:
        return "%s/%s-%03d" % (publisher or pubid, pubid, int(num))

    dt = xd.get_header("Date")
    if not dt:
        utils.warn("neither Number nor Date for '%s'" % xd.filename)
        return 'misc/' + xd.filename

    year = xdfile.year_from_date(dt)
    return "%s/%s/%s%s" % (publisher, year, pubid, dt)
Example #3
0
def main():
    args = utils.get_args('make clues.tsv files')
    outf = utils.open_output()  # should be .zip

    outf.log = False
    outf.toplevel = 'xd'
    outf.write_file('README', open('doc/zip-README').read())

    all_clues = [(ca.pubid, str(xdfile.year_from_date(ca.date)), ca.answer, ca.clue) for ca in xdfile.clues()]

    clues_tsv = ''

    clues_tsv += '\t'.join("pubid year answer clue".split()) + '\n'
    clues_tsv += '\n'.join('\t'.join(cluerow) for cluerow in sorted(all_clues))
    outf.write_file('clues.tsv', clues_tsv)
Example #4
0
def main():
    args = utils.get_args('make clues.tsv files')
    outf = utils.open_output()  # should be .zip

    outf.log = False
    outf.toplevel = 'xd'
    outf.write_file('README', open('doc/zip-README').read())

    all_clues = [(ca.pubid, str(xdfile.year_from_date(ca.date)), ca.answer,
                  ca.clue) for ca in xdfile.clues()]

    clues_tsv = ''

    clues_tsv += '\t'.join("pubid year answer clue".split()) + '\n'
    clues_tsv += '\n'.join('\t'.join(cluerow) for cluerow in sorted(all_clues))
    outf.write_file('clues.tsv', clues_tsv)
Example #5
0
def deduce_xdid(xd, mdtext):

    pubid = find_pubid(mdtext)
    if not pubid:
        publication = get_publication(xd)
        pubid = publication.PublicationAbbr
        # Return None if no pub data
        if not pubid:
            return None

    num = xd.get_header('Number')
    if num:
        return "%s-%03d" % (pubid, int(num))

    dt = xd.get_header("Date")
    if dt:
        year = xdfile.year_from_date(dt)
        return "%s%s" % (pubid, dt)
Example #6
0
def deduce_xdid(xd, mdtext):

    pubid = find_pubid(mdtext)
    if not pubid:
        publication = get_publication(xd)
        pubid = publication.PublicationAbbr
        # Return None if no pub data
        if not pubid:
            return None

    num = xd.get_header('Number')
    if num:
        return "%s-%03d" % (pubid, int(num))

    dt = xd.get_header("Date")
    if dt:
        year = xdfile.year_from_date(dt)
        return "%s%s" % (pubid, dt)