Skip to content
Snippets Groups Projects
Commit 801bcc49 authored by Andreas Klöckner's avatar Andreas Klöckner
Browse files

PEP8 context_matching

parent aa552b85
No related branches found
No related tags found
No related merge requests found
...@@ -26,14 +26,13 @@ THE SOFTWARE. ...@@ -26,14 +26,13 @@ THE SOFTWARE.
""" """
# {{{ id match objects # {{{ id match objects
class AllMatch(object): class AllMatch(object):
def __call__(self, identifier, tag): def __call__(self, identifier, tag):
return True return True
class RegexIdentifierMatch(object): class RegexIdentifierMatch(object):
def __init__(self, id_re, tag_re=None): def __init__(self, id_re, tag_re=None):
self.id_re = id_re self.id_re = id_re
...@@ -50,6 +49,7 @@ class RegexIdentifierMatch(object): ...@@ -50,6 +49,7 @@ class RegexIdentifierMatch(object):
self.id_re.match(identifier) is not None self.id_re.match(identifier) is not None
and self.tag_re.match(tag) is not None) and self.tag_re.match(tag) is not None)
class AlternativeMatch(object): class AlternativeMatch(object):
def __init__(self, matches): def __init__(self, matches):
self.matches = matches self.matches = matches
...@@ -61,6 +61,7 @@ class AlternativeMatch(object): ...@@ -61,6 +61,7 @@ class AlternativeMatch(object):
# }}} # }}}
# {{{ single id match parsing # {{{ single id match parsing
def parse_id_match(id_matches): def parse_id_match(id_matches):
...@@ -109,6 +110,7 @@ def parse_id_match(id_matches): ...@@ -109,6 +110,7 @@ def parse_id_match(id_matches):
# }}} # }}}
# {{{ stack match objects # {{{ stack match objects
# these match from the tail of the stack # these match from the tail of the stack
...@@ -116,10 +118,12 @@ def parse_id_match(id_matches): ...@@ -116,10 +118,12 @@ def parse_id_match(id_matches):
class StackMatchBase(object): class StackMatchBase(object):
pass pass
class AllStackMatch(StackMatchBase): class AllStackMatch(StackMatchBase):
def __call__(self, stack): def __call__(self, stack):
return True return True
class StackIdMatch(StackMatchBase): class StackIdMatch(StackMatchBase):
def __init__(self, id_match, up_match): def __init__(self, id_match, up_match):
self.id_match = id_match self.id_match = id_match
...@@ -138,6 +142,7 @@ class StackIdMatch(StackMatchBase): ...@@ -138,6 +142,7 @@ class StackIdMatch(StackMatchBase):
else: else:
return self.up_match(stack[:-1]) return self.up_match(stack[:-1])
class StackWildcardMatch(StackMatchBase): class StackWildcardMatch(StackMatchBase):
def __init__(self, up_match): def __init__(self, up_match):
self.up_match = up_match self.up_match = up_match
...@@ -159,6 +164,7 @@ class StackWildcardMatch(StackMatchBase): ...@@ -159,6 +164,7 @@ class StackWildcardMatch(StackMatchBase):
# }}} # }}}
# {{{ stack match parsing # {{{ stack match parsing
def parse_stack_match(smatch): def parse_stack_match(smatch):
...@@ -170,7 +176,8 @@ def parse_stack_match(smatch): ...@@ -170,7 +176,8 @@ def parse_stack_match(smatch):
arbitrary number of intervening stack levels. There is currently no way to arbitrary number of intervening stack levels. There is currently no way to
match the top of the stack. match the top of the stack.
Each of the entries is an identifier match as understood by :func:`parse_id_match`. Each of the entries is an identifier match as understood by
:func:`parse_id_match`.
""" """
if isinstance(smatch, StackMatchBase): if isinstance(smatch, StackMatchBase):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment