databaker icon indicating copy to clipboard operation
databaker copied to clipboard

assert_one() failures are noisy and unfriendly

Open StevenMaude opened this issue 9 years ago • 2 comments

Traceback (most recent call last):
  File "/home/me/.virtualenvs/databaker/bin/bake", line 11, in <module>
    sys.exit(main())
  File "/home/me/.virtualenvs/databaker/local/lib/python2.7/site-packages/databaker/bake.py", line 328, in main
    per_file(fn, recipe)
  File "/home/me/.virtualenvs/databaker/local/lib/python2.7/site-packages/databaker/bake.py", line 272, in per_file
    obs = recipe.per_tab(tab)
  File "a02.py", line 7, in per_tab
    obs = tab.filter("All Persons").assert_one().shift(DOWN)
  File "/home/me/.virtualenvs/databaker/local/lib/python2.7/site-packages/xypath/xypath.py", line 425, in assert_one
    len(self.__store)
xypath.xypath.MultipleCellsAssertionError: assert_one() : 2 cells in bag, not 1
exit: 0.089s,  3.129s total

Perhaps it should show the full output if --debug is enabled and otherwise something more concise like so that the user can immediately see the problem:

2 cells in bag, not 1 found in:
  File "a02.py", line 7, in per_tab
obs = tab.filter("All Persons").assert_one().shift(DOWN)

StevenMaude avatar Mar 04 '15 16:03 StevenMaude

:+1:

scraperdragon avatar May 01 '15 13:05 scraperdragon

https://github.com/scraperwiki/databaker/pull/32

scraperdragon avatar May 01 '15 15:05 scraperdragon