summaryrefslogtreecommitdiff
path: root/dumps/dump.py
blob: b36e4a1236216ca928e6d13ff940517d3e5a113a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env python

from sys import argv
from compile import compile
from table2csv import convert

if __name__ == "__main__":
    if len(argv) > 1:
        if argv[1] == 'compile':
            compile(argv[2:])
        elif len(argv) > 2:
            if argv[1] == 'fetch':
                argv.remove('fetch')
            fetch = __import__('_sites.' + argv[1], globals(), locals(), ['fetch'])
            for url in argv[2:]:
                title, tables = fetch.fetch(url)
                i = 1
                for table in tables:
                    convert(table, title + '-' + str(i), argv[1])
                    i += 1