Add helper _get_option_name() which finds name of the option for current Command

Command class has a get_command_name() but it returns the class's name, not the name
of the option as declared in setup cmdclass dict.
This commit is contained in:
Laurent Monin
2014-01-13 15:51:50 +01:00
committed by Wieland Hoffmann
parent 2e247a708d
commit f5197652d2

View File

@@ -366,6 +366,14 @@ except ImportError:
_exit("Babel is required to use this command (see po/README.md)")
def _get_option_name(obj):
"""Returns the name of the option for specified Command object"""
for name, klass in obj.distribution.cmdclass.iteritems():
if obj.__class__ == klass:
return name
raise Exception("No such command class")
class picard_update_countries(Command):
description = "Regenerate countries.py"
user_options = [