markup: pass workdir around, don't recalc all the time

This commit is contained in:
2019-10-19 22:08:42 -07:00
parent ed5236c618
commit e434d3f705
5 changed files with 28 additions and 31 deletions

View File

@ -19,6 +19,7 @@ from django.conf import settings
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'procat2.settings')
django.setup()
from markup.utils import WORKDIR, clean_path
from markup.matching import find_marked_products
from markup.spreadsheet import write_spreadsheet
@ -40,12 +41,11 @@ def main(argv):
fname = args[0]
path = Path(fname)
catname = path.stem
catname = re.sub(r'[^\w]', '_', catname)
workdir = os.path.join(WORKDIR, 'test', clean_path(path.stem))
matches = find_marked_products(fname, subdir, catname, debug=0)
matches = find_marked_products(fname, workdir, debug)
print(f'{len(matches)} product matches')
write_spreadsheet(matches, subdir, catname, path.stem)
write_spreadsheet(matches, workdir, path.stem)
if __name__ == '__main__': sys.exit(main(sys.argv))