From f5197652d2031df24ce246c9b98df4af2dbcbaec Mon Sep 17 00:00:00 2001 From: Laurent Monin Date: Mon, 13 Jan 2014 15:51:50 +0100 Subject: [PATCH] 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. --- setup.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/setup.py b/setup.py index 850ae57d1..723d484e2 100755 --- a/setup.py +++ b/setup.py @@ -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 = [