Closed hynek closed 3 years ago
Y'know, I know I looked at that regex when I put the project together, and I must've gotten tripped up by a canonical Black Swan -- I looked through a bunch of inventories and didn't see any names with spaces, and thought about it for a while and couldn't think of any examples where it would have spaces. I think I then assumed that the Sphinx devs were just being over-cautious for a case that shouldn't occur, and so coded sphobjinv
to only accept entries with spaces. I use re.finditer
to parse the lines of object data, which indeed will just ignore such entries, as you observed.
You reported this at a good time -- I'm just at the cusp of a v2.1 release. And, by pointing me back at that regex, you saved me from a pretty big whoops. As part of addressing #147, I relaxed the constraints on the priority
field, to allow non-integer and non-numeric values. BUT. Obviously, the -?\d+
will only match integers, so I need to rip that back out before any production release.
This means that in addition to a fix here, I need to improve my test suite, at minimum to compare inventory data not run through sphobjinv.Inventory
with the data that makes it into an Inventory
instance.
Thanks very much for the report!
attrs v20.3
inventory to tests/resource
Yep. Biiiiiiig bug.
I attract those kind of things, you know. ;)
Hehe.
And yeah, I should've just used their regex, instead of haring off and making a bunch of assumptions. Woops.
I'm currently writing an objects.inv parser in non-Python and stumbled into something that you might be interested in: contrary to https://sphobjinv.readthedocs.io/en/stable/syntax.html, the name field can indeed contain spaces.
I've encountered it in my very own project, that has the following line:
I tried loading https://www.attrs.org/en/stable/objects.inv with sphobjinv and it seems to silently ignore these entries.
Maybe you can just steal their regex.