Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
aranega committed Oct 25, 2024
1 parent e605626 commit 0500435
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
11 changes: 10 additions & 1 deletion iguala/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,14 @@
from .matchers import as_matcher, cond, extended, is_, regex, save_as
from .paths import as_path

__ALL__ = ["match", "as_matcher", "as_path", "is_not", "cond", "regex", "extended", "save_as"]
__ALL__ = [
"match",
"as_matcher",
"as_path",
"is_not",
"cond",
"regex",
"extended",
"save_as",
]
__version__ = "0.5.3-dev"
13 changes: 9 additions & 4 deletions iguala/matchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ def bindings(self):

def __getitem__(self, key):
if isinstance(key, slice):
return key.step([binding[key.start] for binding in self.bindings if key.start in binding])
return key.step(
[
binding[key.start]
for binding in self.bindings
if key.start in binding
]
)
return [binding[key] for binding in self.bindings if key in binding]

def __str__(self):
Expand Down Expand Up @@ -176,8 +182,7 @@ def match_context(self, obj, context):
return [context]


class LogicalMatcher(Matcher):
...
class LogicalMatcher(Matcher): ...


class NotMatcher(Matcher):
Expand Down Expand Up @@ -603,4 +608,4 @@ def as_matcher(obj):
cond = ConditionalMatcher
regex = RegexMatcher
is_ = IdentityMatcher
save_as = lambda alias: SaveNodeMatcher(alias, None)
save_as = lambda alias: SaveNodeMatcher(alias, None)
4 changes: 2 additions & 2 deletions iguala/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def as_path(s, dictkey=False):
# return LambdaPath(s)
if not isinstance(s, str):
return s.as_path()
if s == '_':
if s == "_":
return WildcardPath()
if s == "*":
return ChildrenRecursivePath()
Expand All @@ -162,6 +162,6 @@ def as_path(s, dictkey=False):
NamedRecursivePath(as_path(s[:-1], dictkey=dictkey)),
)
)
if s.startswith('!'):
if s.startswith("!"):
return WildcardPath(excluding=[s[1:]])
return dict_cls(s)

0 comments on commit 0500435

Please sign in to comment.