Skip to content

Commit

Permalink
Use 'next' to find a rule.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed May 18, 2024
1 parent ba406ea commit 65d1ba8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions cssutils/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,12 +817,11 @@ def __setitem__(self, prefix, namespaceURI):

def __findrule(self, prefix):
# returns namespace rule where prefix == key
for rule in filter(
lambda r: r.type == r.NAMESPACE_RULE,
found = filter(
lambda r: r.type == r.NAMESPACE_RULE and r.prefix == prefix,
reversed(self.parentStyleSheet.cssRules),
):
if rule.prefix == prefix:
return rule
)
return next(found, None)

@property
def namespaces(self):
Expand Down

0 comments on commit 65d1ba8

Please sign in to comment.