mirror of https://github.com/python/cpython.git
Add optional section titles to format_all.
Allow for missing section titles in format_all and format_index.
This commit is contained in:
parent
b1d8a259e3
commit
21c4b5f66a
|
@ -410,7 +410,7 @@ def do_search(self):
|
||||||
emit(ONE_HIT, count=1)
|
emit(ONE_HIT, count=1)
|
||||||
else:
|
else:
|
||||||
emit(FEW_HITS, count=len(hits))
|
emit(FEW_HITS, count=len(hits))
|
||||||
self.format_all(hits)
|
self.format_all(hits, headers=0)
|
||||||
else:
|
else:
|
||||||
emit(MANY_HITS, count=len(hits))
|
emit(MANY_HITS, count=len(hits))
|
||||||
self.format_index(hits)
|
self.format_index(hits)
|
||||||
|
@ -441,9 +441,22 @@ def last_changed(self, files):
|
||||||
print time.strftime(LAST_CHANGED,
|
print time.strftime(LAST_CHANGED,
|
||||||
time.localtime(time.time()))
|
time.localtime(time.time()))
|
||||||
|
|
||||||
def format_all(self, files, edit=1):
|
def format_all(self, files, edit=1, headers=1):
|
||||||
|
sec = 0
|
||||||
for file in files:
|
for file in files:
|
||||||
self.dir.show(file, edit=edit)
|
try:
|
||||||
|
entry = self.dir.open(file)
|
||||||
|
except NoSuchFile:
|
||||||
|
continue
|
||||||
|
if headers and entry.sec != sec:
|
||||||
|
sec = entry.sec
|
||||||
|
try:
|
||||||
|
title = SECTION_TITLES[sec]
|
||||||
|
except KeyError:
|
||||||
|
title = "Untitled"
|
||||||
|
emit("\n<HR>\n<H1>%(sec)s. %(title)s</H1>\n",
|
||||||
|
sec=sec, title=title)
|
||||||
|
entry.show(edit=edit)
|
||||||
|
|
||||||
def do_index(self):
|
def do_index(self):
|
||||||
self.prologue(T_INDEX)
|
self.prologue(T_INDEX)
|
||||||
|
@ -462,7 +475,11 @@ def format_index(self, files, add=0):
|
||||||
emit(INDEX_ADDSECTION, sec=sec)
|
emit(INDEX_ADDSECTION, sec=sec)
|
||||||
emit(INDEX_ENDSECTION, sec=sec)
|
emit(INDEX_ENDSECTION, sec=sec)
|
||||||
sec = entry.sec
|
sec = entry.sec
|
||||||
emit(INDEX_SECTION, sec=sec, title=SECTION_TITLES[sec])
|
try:
|
||||||
|
title = SECTION_TITLES[sec]
|
||||||
|
except KeyError:
|
||||||
|
title = "Untitled"
|
||||||
|
emit(INDEX_SECTION, sec=sec, title=title)
|
||||||
emit(INDEX_ENTRY, entry)
|
emit(INDEX_ENTRY, entry)
|
||||||
if sec:
|
if sec:
|
||||||
if add:
|
if add:
|
||||||
|
|
Loading…
Reference in New Issue