Skip to content

Commit

Permalink
Some fixes in Matches methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Toilal committed Nov 1, 2015
1 parent cb287fd commit 9c0fe70
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions rebulk/match.py
Expand Up @@ -210,6 +210,9 @@ def chain_before(self, position, seps, start=0, predicate=None, index=None):
:return:
:rtype:
"""
if hasattr(position, 'start'):
position = position.start

chain = _BaseMatches._base()
position = min(self.max_end, position)

Expand Down Expand Up @@ -242,6 +245,8 @@ def chain_after(self, position, seps, end=None, predicate=None, index=None):
:return:
:rtype:
"""
if hasattr(position, 'end'):
position = position.end
chain = _BaseMatches._base()

if end is None:
Expand Down Expand Up @@ -327,19 +332,16 @@ def holes(self, start=0, end=None, formatter=None, ignore=None, seps=None, predi
else:
end = min(self.max_end, end)
ret = _BaseMatches._base()
current = []
hole = False
rindex = start

loop_start = self._hole_start(start, ignore)

for rindex in range(loop_start, end):
for starting in self.starting(rindex):
if starting not in current and (not ignore or not ignore(starting)):
current.append(starting)
for ending in self.ending(rindex):
if ending in current:
current.remove(ending)
current = []
for at_index in self.at_index(rindex):
if not ignore or not ignore(at_index):
current.append(at_index)

if seps and hole and self.input_string and self.input_string[rindex] in seps:
hole = False
Expand Down

0 comments on commit 9c0fe70

Please sign in to comment.