issue #3 adding "commandline" feature
This commit is contained in:
1 parent
44b8d3328a
commit
3df015d132
4 files changed
+166
-68
No files matched your search
@@ -1,6 +1,35 @@
|
||||
import argparse
|
||||
|
||||
import pytz
|
||||
import datetime as dt
|
||||
|
||||
|
||||
class CustomFormatter(argparse.RawTextHelpFormatter):
|
||||
def _format_action_invocation(self, action):
|
||||
if not action.option_strings:
|
||||
metavar, = self._metavar_formatter(action, action.dest)(1)
|
||||
return metavar
|
||||
else:
|
||||
parts = []
|
||||
# if the Optional doesn't take a value, format is:
|
||||
# -s, --long
|
||||
if action.nargs == 0:
|
||||
parts.extend(action.option_strings)
|
||||
|
||||
# if the Optional takes a value, format is:
|
||||
# -s ARGS, --long ARGS
|
||||
# change to
|
||||
# -s, --long ARGS
|
||||
else:
|
||||
default = action.dest.upper()
|
||||
args_string = self._format_args(action, default)
|
||||
for option_string in action.option_strings:
|
||||
# parts.append('%s %s' % (option_string, args_string))
|
||||
parts.append('%s' % option_string)
|
||||
parts[-1] += ' %s' % args_string
|
||||
return ', '.join(parts)
|
||||
|
||||
|
||||
def possible_timezones(tz_offset, common_only=True):
|
||||
# pick one of the timezone collections
|
||||
timezones = pytz.common_timezones if common_only else pytz.all_timezones
|
||||
|
||||
Reference in new issue
Block a user