Commit 2f303480 authored by Fred Drake's avatar Fred Drake

Remove a bare try/except completely -- it just did not make sense!

Add a comment elsewhere making clear an assumption in the code.
parent db9adc65
...@@ -113,18 +113,15 @@ class AbstractFormatter: ...@@ -113,18 +113,15 @@ class AbstractFormatter:
def format_counter(self, format, counter): def format_counter(self, format, counter):
label = '' label = ''
for c in format: for c in format:
try: if c == '1':
if c == '1': label = label + ('%d' % counter)
label = label + ('%d' % counter) elif c in 'aA':
elif c in 'aA': if counter > 0:
if counter > 0: label = label + self.format_letter(c, counter)
label = label + self.format_letter(c, counter) elif c in 'iI':
elif c in 'iI': if counter > 0:
if counter > 0: label = label + self.format_roman(c, counter)
label = label + self.format_roman(c, counter) else:
else:
label = label + c
except:
label = label + c label = label + c
return label return label
...@@ -132,6 +129,9 @@ class AbstractFormatter: ...@@ -132,6 +129,9 @@ class AbstractFormatter:
label = '' label = ''
while counter > 0: while counter > 0:
counter, x = divmod(counter-1, 26) counter, x = divmod(counter-1, 26)
# This makes a strong assumption that lowercase letters
# and uppercase letters form two contiguous blocks, with
# letters in order!
s = chr(ord(case) + x) s = chr(ord(case) + x)
label = s + label label = s + label
return label return label
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment