def span(self, raw):
"""Parses the input string search for a span pattern and if if found, returns a slice from the History list.
:param raw: str - string potentially containing a span of the forms a..b, a:b, a:, ..b
:return: List[HistoryItem] - slice from the History list
"""
if raw.lower() in ('*', '-', 'all'):
raw = ':'
results = self.spanpattern.search(raw)
if not results:
raise IndexError
if not results.group('separator'):
return [self[self._to_index(results.group('start'))]]
start = self._to_index(results.group('start')) or 0 # Ensure start is not None
end = self._to_index(results.group('end'))
reverse = False
if end is not None:
if end < start:
(start, end) = (end, start)
reverse = True
end += 1
result = self[start:end]
if reverse:
result.reverse()
return result
评论列表
文章目录