summaryrefslogtreecommitdiff
path: root/cmd2/history.py
diff options
context:
space:
mode:
Diffstat (limited to 'cmd2/history.py')
-rw-r--r--cmd2/history.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/cmd2/history.py b/cmd2/history.py
index fc1691b4..bc6c32ce 100644
--- a/cmd2/history.py
+++ b/cmd2/history.py
@@ -20,8 +20,9 @@ from .parsing import (
@attr.s(frozen=True)
-class HistoryItem():
+class HistoryItem:
"""Class used to represent one command in the history list"""
+
_listformat = ' {:>4} {}'
_ex_listformat = ' {:>4}x {}'
@@ -97,6 +98,7 @@ class History(list):
Developers interested in accessing previously entered commands can use this
class to gain access to the historical record.
"""
+
def __init__(self, seq=()) -> None:
super().__init__(seq)
self.session_start_index = 0
@@ -230,7 +232,7 @@ class History(list):
if include_persisted:
result = self[:end]
else:
- result = self[self.session_start_index:end]
+ result = self[self.session_start_index : end]
elif start is not None:
# there was no separator so it's either a positive or negative integer
result = [self[start]]
@@ -239,7 +241,7 @@ class History(list):
if include_persisted:
result = self[:]
else:
- result = self[self.session_start_index:]
+ result = self[self.session_start_index :]
return result
def str_search(self, search: str, include_persisted: bool = False) -> List[HistoryItem]:
@@ -249,6 +251,7 @@ class History(list):
:param include_persisted: if True, then search full history including persisted history
:return: a list of history items, or an empty list if the string was not found
"""
+
def isin(history_item):
"""filter function for string search of history"""
sloppy = utils.norm_fold(search)
@@ -256,7 +259,7 @@ class History(list):
inexpanded = sloppy in utils.norm_fold(history_item.expanded)
return inraw or inexpanded
- search_list = self if include_persisted else self[self.session_start_index:]
+ search_list = self if include_persisted else self[self.session_start_index :]
return [item for item in search_list if isin(item)]
def regex_search(self, regex: str, include_persisted: bool = False) -> List[HistoryItem]:
@@ -275,7 +278,7 @@ class History(list):
"""filter function for doing a regular expression search of history"""
return finder.search(hi.raw) or finder.search(hi.expanded)
- search_list = self if include_persisted else self[self.session_start_index:]
+ search_list = self if include_persisted else self[self.session_start_index :]
return [itm for itm in search_list if isin(itm)]
def truncate(self, max_length: int) -> None: