From 58b4beca963e715277cefe8cb7643366c1852a79 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 13 Aug 2013 11:09:55 +0530 Subject: [PATCH] Show only the first two version numbers if the third is zero --- src/calibre/constants.py | 4 +++- src/calibre/utils/config.py | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/calibre/constants.py b/src/calibre/constants.py index e0c0f6b845..d4d73e64a7 100644 --- a/src/calibre/constants.py +++ b/src/calibre/constants.py @@ -217,9 +217,11 @@ else: # }}} def get_version(): - '''Return version string that indicates if we are running in a dev env''' + '''Return version string for display to user ''' dv = os.environ.get('CALIBRE_DEVELOP_FROM', None) v = __version__ + if numeric_version[-1] == 0: + v = v[:-2] if getattr(sys, 'frozen', False) and dv and os.path.abspath(dv) in sys.path: v += '*' if iswindows and is64bit: diff --git a/src/calibre/utils/config.py b/src/calibre/utils/config.py index fbd4c47a35..b002a019ae 100644 --- a/src/calibre/utils/config.py +++ b/src/calibre/utils/config.py @@ -12,7 +12,7 @@ from optparse import OptionParser as _OptionParser, OptionGroup from optparse import IndentedHelpFormatter from calibre.constants import (config_dir, CONFIG_DIR_MODE, __appname__, - __version__, __author__) + get_version, __author__) from calibre.utils.lock import ExclusiveFile from calibre.utils.config_base import (make_config_dir, Option, OptionValues, OptionSet, ConfigInterface, Config, prefs, StringConfig, ConfigProxy, @@ -76,7 +76,7 @@ class OptionParser(_OptionParser): def __init__(self, usage='%prog [options] filename', - version='%%prog (%s %s)'%(__appname__, __version__), + version=None, epilog=None, gui_mode=False, conflict_handler='resolve', @@ -89,6 +89,8 @@ class OptionParser(_OptionParser): epilog = _('Created by ')+colored(__author__, fg='cyan') usage += '\n\n'+_('''Whenever you pass arguments to %prog that have spaces in them, ''' '''enclose the arguments in quotation marks.''')+'\n' + if version is None: + version = '%%prog (%s %s)'%(__appname__, get_version()) _OptionParser.__init__(self, usage=usage, version=version, epilog=epilog, formatter=CustomHelpFormatter(), conflict_handler=conflict_handler, **kwds)