X-Git-Url: http://git.veekun.com/zzz-pokedex.git/blobdiff_plain/03a0a2983a582ddf3570a337f94d236b0c8d4618..13f7d540683fc74cf811ee70f4f3305ef261ee6d:/pokedex/db/load.py?ds=inline diff --git a/pokedex/db/load.py b/pokedex/db/load.py index d5502ea..df0d0f1 100644 --- a/pokedex/db/load.py +++ b/pokedex/db/load.py @@ -2,7 +2,6 @@ import csv import fnmatch import os.path -import pkg_resources import sys from sqlalchemy.orm.attributes import instrumentation_registry @@ -11,6 +10,7 @@ import sqlalchemy.types from pokedex.db import metadata import pokedex.db.tables as tables +from pokedex.defaults import get_default_csv_dir def _get_table_names(metadata, patterns): @@ -121,8 +121,8 @@ def load(session, tables=[], directory=None, drop_tables=False, verbose=False): print_start, print_status, print_done = _get_verbose_prints(verbose) - if not directory: - directory = pkg_resources.resource_filename('pokedex', 'data/csv') + if directory is None: + directory = get_default_csv_dir() table_names = _get_table_names(metadata, tables) table_objs = [metadata.tables[name] for name in table_names] @@ -179,7 +179,7 @@ def load(session, tables=[], directory=None, drop_tables=False, verbose=False): session.commit() new_rows[:] = [] - progress = "{0}%".format(100 * csvfile.tell() // csvsize) + progress = "%d%%" % (100 * csvfile.tell() // csvsize) print_status(progress) for csvs in reader: @@ -276,7 +276,7 @@ def dump(session, tables=[], directory=None, verbose=False): if not directory: - directory = pkg_resources.resource_filename('pokedex', 'data/csv') + directory = get_default_csv_dir() table_names = _get_table_names(metadata, tables) table_names.sort()