from . import command as _command
from . import error as _error
from . import feeds as _feeds
+from . import version as _version
+
+
+class FullVersionAction (_argparse.Action):
+ def __call__(self, *args, **kwargs):
+ for package,version in _version.get_versions():
+ print('{} {}'.format(package, version))
+ _sys.exit(0)
def run(*args, **kwargs):
parser.add_argument(
'-v', '--version', action='version',
version='%(prog)s {}'.format(__version__))
+ parser.add_argument(
+ '--full-version', action=FullVersionAction, nargs=0,
+ help='print the version information of all related packages and exit')
parser.add_argument(
'-c', '--config', metavar='PATH', default=[], action='append',
help='path to the configuration file')
--- /dev/null
+# Copyright
+
+"""Calculate version numbers for this package and its dependencies
+
+This makes it easier for users to submit useful bug reports.
+"""
+
+import importlib as _importlib
+import sys as _sys
+
+from . import __version__
+
+
+def get_rss2email_version(package):
+ return __version__
+
+def get_python_version(package):
+ return _sys.version
+
+def get_python_package_version(package):
+ try:
+ module = _importlib.import_module(package)
+ except ImportError as e:
+ return None
+ return getattr(module, '__version__', 'unknown')
+
+def get_versions(packages=None):
+ if not packages:
+ packages = ['rss2email', 'python', 'feedparser', 'html2text']
+ for package in packages:
+ get = globals().get(
+ 'get_{}_version'.format(package),
+ get_python_package_version)
+ version = get(package=package)
+ yield (package, version)