예제 #1
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('inventarios')
    parser.add_argument('metadata')
    parser.add_argument('-o', '--output')
    parser.add_argument('-f', '--format')
    args = parser.parse_args()

    problems = []
    problems.extend(
        find_mention_problems(parse_mentions(Book(args.inventarios))))
    problems.extend(find_meta_problems(parse_metadata(args.metadata)))
    write(problems, args.output, header=HEADER, format=args.format)
예제 #2
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('inventarios')
    parser.add_argument('metadata')
    parser.add_argument('bne')
    parser.add_argument('-o', '--output')
    parser.add_argument('-f', '--format')
    args = parser.parse_args()
    header = ('mid', 'bid', 'lid', 'year', 'pos', 'short', 'title', 'lang',
              'topic', 'area', 'height', 'exists', 'material', 'author')

    meta = parse_metadata(args.metadata)
    meta = {int(m['id']): m for m in meta}
    bne = read(args.bne)
    bne = {int(b['id']): b for b in bne}
    mentions = parse_mentions(Book(args.inventarios))

    table = table_of_mentions(mentions, meta, bne, header)
    write(table, args.output, header=header, format=args.format)
예제 #3
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('inventarios')
    parser.add_argument('-o', '--output')
    parser.add_argument('-f', '--format')
    args = parser.parse_args()

    books = {}
    for m in parse_mentions(Book(args.inventarios)):
        if not m['book_id']:
            print('Mention with empty id: {!r}'.format(m), file=sys.stderr)
            continue

        if not books.get(int(m['book_id'])):
            m['idx'] = '{}.{}'.format(m['list_id'], str(m['pos']).zfill(3))
            books[int(m['book_id'])] = m
        else:
            books[int(m['book_id'])]['title'] = m['title']

    header = ('id', 'idx', 'short', 'title', 'topic', 'lang', 'ref_old', 'ref',
              'bb')
    write(get_entries(books), args.output, header=header, format=args.format)
예제 #4
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('inventarios')
    parser.add_argument('metadata')
    parser.add_argument('bne')
    parser.add_argument('-o', '--output', default='.')
    parser.add_argument('-d', '--db')
    parser.add_argument('-s', '--schema')
    args = parser.parse_args()
    meta = parse_metadata(args.metadata)
    meta = {int(m['id']): m for m in meta}
    bne = read(args.bne)
    bne = {int(b['id']): b for b in bne}
    mentions = list(parse_mentions(Book(args.inventarios)))

    books_table = table_of_books(mentions, meta, bne)
    listings_table = table_of_listings(mentions, meta, bne)
    mentions_table = table_of_mentions(mentions, meta, bne)
    if args.db:
        dump_to_db(args, books_table, listings_table, mentions_table)
    else:
        dump_to_csv(args, books_table, listings_table, mentions_table)
예제 #5
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('inventarios')
    parser.add_argument('-o', '--output')
    parser.add_argument('-f', '--format')
    args = parser.parse_args()

    books = {}
    for m in parse_mentions(Book(args.inventarios)):
        if not m['book_id']:
            print('Mention with empty id: {!r}'.format(m), file=sys.stderr)
            continue

        if m['book_id'] not in books:
            books[m['book_id']] = {}
        books[int(m['book_id'])][str(m['year'])] = m['title']

    header = ["ID Libro"] + YEARS

    write(titles_per_year(books, header),
          args.output,
          header=header,
          format=args.format)