We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 308b977 commit cb6b94bCopy full SHA for cb6b94b
1 file changed
dpath/segments.py
@@ -230,9 +230,12 @@ def match(segments: Path, glob: Glob):
230
231
try:
232
# If search path segment (s) is an int and the current evaluated index (g) is int-like,
233
- # then g is surely a sequence index. Convert it to int and compare.
234
- if isinstance(s, int) and isinstance(g, str) and (g.count("-") == 0 or g.lstrip("-").isdigit()):
235
- return s == int(g)
+ # then g is surely a sequence index as well. Convert it to int and compare.
+ if isinstance(s, int) and isinstance(g, str):
+ neg_c = g.count("-")
236
+
237
+ if (neg_c == 0 and g.isdigit()) or (neg_c == 1 and g.lstrip("-").isdigit()):
238
+ return s == int(g)
239
240
# Let's see if the glob matches. We will turn any kind of
241
# exception while attempting to match into a False for the
0 commit comments