Searching in JAMS with `None` and `str` values
See original GitHub issueI’m getting a TypeError
when searching annotations within a JAMS file that contain a specific key that can either be a string or a None
.
Here an example:
when I do something this:
jam.search(namespace="segment_open").search(**{"Sandbox.boundaries_id": "sf"})
and some annotations inside jam
have boundaries_id=None
and others have boundaries_id="sf"
, the search
method raises a TypeError
, like this:
/home/uri/anaconda3/lib/python3.6/site-packages/jams/core.py in search(self, **kwargs)
1340
1341 for annotation in self:
-> 1342 if annotation.search(**kwargs):
1343 results.append(annotation)
1344
/home/uri/anaconda3/lib/python3.6/site-packages/jams/core.py in search(self, **kwargs)
449
450 if isinstance(obj, JObject):
--> 451 match |= obj.search(**r_query)
452
453 return match
/home/uri/anaconda3/lib/python3.6/site-packages/jams/core.py in search(self, **kwargs)
442 for key in r_query:
443 if hasattr(self, key):
--> 444 match |= match_query(getattr(self, key), r_query[key])
445
446 if not match:
/home/uri/anaconda3/lib/python3.6/site-packages/jams/core.py in match_query(string, query)
1836
1837 elif isinstance(query, six.string_types):
-> 1838 return re.match(query, string) is not None
1839
1840 else:
/home/uri/anaconda3/lib/python3.6/re.py in match(pattern, string, flags)
170 """Try to apply the pattern at the start of the string, returning
171 a match object, or None if no match was found."""
--> 172 return _compile(pattern, flags).match(string)
173
174 def fullmatch(pattern, string, flags=0):
TypeError: expected string or bytes-like object
Is there a way to circumvent this? Shouldn’t search
allow for this type of searches? Thanks!
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
JAMS 7.X User Guide
ValidationType This property allows you to select the type of validation JAMS can perform on the Parameter value. The validation types are: None:...
Read more >jams 0.3.2 documentation
Search a JAMS object for matching objects. Parameters: kwargs : keyword arguments.
Read more >Pythonic way of converting 'None' string to None
Let's say I have the following yaml file and the value in the 4th row should be None . How can I convert...
Read more >TypeError: can only concatenate str (not "NoneType") to str
The Python "TypeError: can only concatenate str (not "NoneType") to str" occurs when we try to concatenate a string and a None value....
Read more >How do I define search filters? - JAM Software
Defining a filter. In order to create a new filter, follow these steps: 1.Click "+". 2.In the first selection box, select what you...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think you missed a
is not None
in your work around. This seems to work now:Yeah, sorry about that – you’re right.