Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
loopy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ben Sepanski
loopy
Commits
801bcc49
Commit
801bcc49
authored
11 years ago
by
Andreas Klöckner
Browse files
Options
Downloads
Patches
Plain Diff
PEP8 context_matching
parent
aa552b85
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
loopy/context_matching.py
+10
-3
10 additions, 3 deletions
loopy/context_matching.py
with
10 additions
and
3 deletions
loopy/context_matching.py
+
10
−
3
View file @
801bcc49
...
@@ -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
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment