mirror of
https://github.com/python/cpython.git
synced 2025-12-07 09:47:28 +00:00
Fix so we clear or reinitialize various data structures before populating
(allows the same FancyGetopt object to be used multiple times with different option tables).
This commit is contained in:
parent
f9d20c3786
commit
0fd2dd6db0
1 changed files with 5 additions and 0 deletions
|
|
@ -93,6 +93,7 @@ class FancyGetopt:
|
||||||
|
|
||||||
|
|
||||||
def _build_index (self):
|
def _build_index (self):
|
||||||
|
self.option_index.clear()
|
||||||
for option in self.option_table:
|
for option in self.option_table:
|
||||||
self.option_index[option[0]] = option
|
self.option_index[option[0]] = option
|
||||||
|
|
||||||
|
|
@ -153,6 +154,10 @@ class FancyGetopt:
|
||||||
the option table. Called by 'getopt()' before it can do
|
the option table. Called by 'getopt()' before it can do
|
||||||
anything worthwhile."""
|
anything worthwhile."""
|
||||||
|
|
||||||
|
self.long_opts = []
|
||||||
|
self.short_opts = []
|
||||||
|
self.short2long.clear()
|
||||||
|
|
||||||
for option in self.option_table:
|
for option in self.option_table:
|
||||||
try:
|
try:
|
||||||
(long, short, help) = option
|
(long, short, help) = option
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue