diff options
Diffstat (limited to 'doxygen/man/man3/cmd2_History.3')
-rw-r--r-- | doxygen/man/man3/cmd2_History.3 | 228 |
1 files changed, 228 insertions, 0 deletions
diff --git a/doxygen/man/man3/cmd2_History.3 b/doxygen/man/man3/cmd2_History.3 new file mode 100644 index 0000000..90938fa --- /dev/null +++ b/doxygen/man/man3/cmd2_History.3 @@ -0,0 +1,228 @@ +.TH "cmd2::History" 3 "Fri Sep 9 2011" "Cmd2" \" -*- nroff -*- +.ad l +.nh +.SH NAME +cmd2::History \- +.SH SYNOPSIS +.br +.PP +.SS "Public Member Functions" + +.in +1c +.ti -1c +.RI "def \fBappend\fP" +.br +.ti -1c +.RI "def \fBextend\fP" +.br +.ti -1c +.RI "def \fBget\fP" +.br +.ti -1c +.RI "def \fBsearch\fP" +.br +.ti -1c +.RI "def \fBspan\fP" +.br +.ti -1c +.RI "def \fBto_index\fP" +.br +.ti -1c +.RI "def \fBzero_based_index\fP" +.br +.in -1c +.SS "Static Public Attributes" + +.in +1c +.ti -1c +.RI "tuple \fBrangePattern\fP = re\&.compile(r'^\\s*(?P<start>[\\d]+)?\\s*\\-\\s*(?P<end>[\\d]+)?\\s*$')" +.br +.ti -1c +.RI "tuple \fBspanpattern\fP = re\&.compile(r'^\\s*(?P<start>\\-?\\d+)?\\s*(?P<separator>:|(\\\&.{2,}))?\\s*(?P<end>\\-?\\d+)?\\s*$')" +.br +.in -1c +.SH "Detailed Description" +.PP +.PP +.nf +A list of HistoryItems that knows how to respond to user requests. +>>> h = History([HistoryItem('first'), HistoryItem('second'), HistoryItem('third'), HistoryItem('fourth')]) +>>> h.span('-2..') +['third', 'fourth'] +>>> h.span('2..3') +['second', 'third'] +>>> h.span('3') +['third'] +>>> h.span(':') +['first', 'second', 'third', 'fourth'] +>>> h.span('2..') +['second', 'third', 'fourth'] +>>> h.span('-1') +['fourth'] +>>> h.span('-2..-3') +['third', 'second'] +>>> h.search('o') +['second', 'fourth'] +>>> h.search('/IR/') +['first', 'third'] +.fi +.PP + +.PP +Definition at line 1304 of file cmd2\&.py'\&. +.SH "Member Function Documentation" +.PP +.SS "def cmd2::History::append (self, new)" +.PP +Definition at line 1368 of file cmd2\&.py'\&. +.PP +Referenced by extend()\&. +.PP +.nf +1368 +1369 def append(self, new): +1370 new = HistoryItem(new) +1371 list\&.append(self, new) + new\&.idx = len(self) +.fi +.SS "def cmd2::History::extend (self, new)" +.PP +Definition at line 1372 of file cmd2\&.py'\&. +.PP +References cmd2::StubbornDict::append, and append()\&. +.PP +.nf +1372 +1373 def extend(self, new): +1374 for n in new: +1375 self\&.append(n) + +.fi +.SS "def cmd2::History::get (self, getme = \fCNone\fP, fromEnd = \fCFalse\fP)" +.PP +Definition at line 1376 of file cmd2\&.py'\&. +.PP +.nf +1376 +1377 def get(self, getme=None, fromEnd=False): +1378 if not getme: +1379 return self +1380 try: +1381 getme = int(getme) +1382 if getme < 0: +1383 return self[:(-1 * getme)] +1384 else: +1385 return [self[getme-1]] +1386 except IndexError: +1387 return [] +1388 except ValueError: +1389 rangeResult = self\&.rangePattern\&.search(getme) +1390 if rangeResult: +1391 start = rangeResult\&.group('start') or None +1392 end = rangeResult\&.group('start') or None +1393 if start: +1394 start = int(start) - 1 +1395 if end: +1396 end = int(end) +1397 return self[start:end] +1398 +1399 getme = getme\&.strip() +1400 +1401 if getme\&.startswith(r'/') and getme\&.endswith(r'/'): +1402 finder = re\&.compile(getme[1:-1], re\&.DOTALL | re\&.MULTILINE | re\&.IGNORECASE) +1403 def isin(hi): +1404 return finder\&.search(hi) +1405 else: +1406 def isin(hi): +1407 return (getme\&.lower() in hi\&.lowercase) +1408 return [itm for itm in self if isin(itm)] + +.fi +.SS "def cmd2::History::search (self, target)" +.PP +Definition at line 1337 of file cmd2\&.py'\&. +.PP +.nf +1337 +1338 def search(self, target): +1339 target = target\&.strip() +1340 if target[0] == target[-1] == '/' and len(target) > 1: +1341 target = target[1:-1] +1342 else: +1343 target = re\&.escape(target) +1344 pattern = re\&.compile(target, re\&.IGNORECASE) + return [s for s in self if pattern\&.search(s)] +.fi +.SS "def cmd2::History::span (self, raw)" +.PP +Definition at line 1346 of file cmd2\&.py'\&. +.PP +References to_index()\&. +.PP +.nf +1346 +1347 def span(self, raw): +1348 if raw\&.lower() in ('*', '-', 'all'): +1349 raw = ':' +1350 results = self\&.spanpattern\&.search(raw) +1351 if not results: +1352 raise IndexError +1353 if not results\&.group('separator'): +1354 return [self[self\&.to_index(results\&.group('start'))]] +1355 start = self\&.to_index(results\&.group('start')) +1356 end = self\&.to_index(results\&.group('end')) +1357 reverse = False +1358 if end is not None: +1359 if end < start: +1360 (start, end) = (end, start) +1361 reverse = True +1362 end += 1 +1363 result = self[start:end] +1364 if reverse: +1365 result\&.reverse() +1366 return result + +.fi +.SS "def cmd2::History::to_index (self, raw)" +.PP +Definition at line 1331 of file cmd2\&.py'\&. +.PP +References zero_based_index()\&. +.PP +Referenced by span()\&. +.PP +.nf +1331 +1332 def to_index(self, raw): +1333 if raw: +1334 result = self\&.zero_based_index(int(raw)) +1335 else: +1336 result = None + return result +.fi +.SS "def cmd2::History::zero_based_index (self, onebased)" +.PP +Definition at line 1326 of file cmd2\&.py'\&. +.PP +Referenced by to_index()\&. +.PP +.nf +1326 +1327 def zero_based_index(self, onebased): +1328 result = onebased +1329 if result > 0: +1330 result -= 1 + return result +.fi +.SH "Member Data Documentation" +.PP +.SS "tuple \fBcmd2::History::rangePattern\fP = re\&.compile(r'^\\s*(?P<start>[\\d]+)?\\s*\\-\\s*(?P<end>[\\d]+)?\\s*$')\fC [static]\fP" +.PP +Definition at line 1367 of file cmd2\&.py'\&. +.SS "tuple \fBcmd2::History::spanpattern\fP = re\&.compile(r'^\\s*(?P<start>\\-?\\d+)?\\s*(?P<separator>:|(\\\&.{2,}))?\\s*(?P<end>\\-?\\d+)?\\s*$')\fC [static]\fP" +.PP +Definition at line 1345 of file cmd2\&.py'\&. + +.SH "Author" +.PP +Generated automatically by Doxygen for Cmd2 from the source code'\&. |