Commit 815e2cfd authored by Michal Čihař's avatar Michal Čihař

Share code for getting module version

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 4042e2ce
...@@ -87,6 +87,22 @@ def get_optional_versions(): ...@@ -87,6 +87,22 @@ def get_optional_versions():
return result return result
def get_single(name,url, module, required, getter='__version__'):
"""Returns version information for single module"""
mod = get_version_module(module, name, url)
version_getter = getattr(mod, getter)
if hasattr(version_getter, '__call__'):
current = version_getter()
else:
current = version_getter
return (
name,
url,
current,
required,
)
def get_versions(): def get_versions():
''' '''
Returns list of used versions. Returns list of used versions.
...@@ -100,54 +116,42 @@ def get_versions(): ...@@ -100,54 +116,42 @@ def get_versions():
'2.7', '2.7',
)) ))
name = 'Django' result.append(get_single(
url = 'https://www.djangoproject.com/' 'Django',
mod = get_version_module('django', name, url) 'https://www.djangoproject.com/',
result.append(( 'django',
name,
url,
mod.get_version(),
'1.8', '1.8',
'get_version'
)) ))
name = 'six' result.append(get_single(
url = 'https://pypi.python.org/pypi/six' 'six',
mod = get_version_module('six', name, url) 'https://pypi.python.org/pypi/six',
result.append(( 'six',
name,
url,
mod.__version__,
'1.7.0', '1.7.0',
)) ))
name = 'python-social-auth' result.append(get_single(
url = 'http://psa.matiasaguirre.net/' 'python-social-auth',
mod = get_version_module('social', name, url) 'http://psa.matiasaguirre.net/',
result.append(( 'social',
name,
url,
mod.__version__,
'0.2.0', '0.2.0',
)) ))
name = 'Translate Toolkit' result.append(get_single(
url = 'http://toolkit.translatehouse.org/' 'Translate Toolkit',
mod = get_version_module('translate.__version__', name, url) 'http://toolkit.translatehouse.org/',
result.append(( 'translate.__version__',
name,
url,
mod.sver,
'1.10.0', '1.10.0',
'sver',
)) ))
name = 'Whoosh' result.append(get_single(
url = 'http://bitbucket.org/mchaput/whoosh/' 'Whoosh',
mod = get_version_module('whoosh', name, url) 'http://bitbucket.org/mchaput/whoosh/',
result.append(( 'whoosh',
name,
url,
mod.versionstring(),
'2.5', '2.5',
'versionstring',
)) ))
try: try:
...@@ -160,63 +164,46 @@ def get_versions(): ...@@ -160,63 +164,46 @@ def get_versions():
except OSError: except OSError:
raise Exception('Failed to run git, please install it.') raise Exception('Failed to run git, please install it.')
name = 'Pillow (PIL)' result.append(get_single(
url = 'http://python-imaging.github.io/' 'Pillow (PIL)',
mod = get_version_module('PIL.Image', name, url) 'http://python-imaging.github.io/',
result.append(( 'PIL.Image',
name,
url,
mod.VERSION,
'1.1.6', '1.1.6',
'VERSION',
)) ))
name = 'dateutil' result.append(get_single(
url = 'http://labix.org/python-dateutil' 'dateutil',
mod = get_version_module('dateutil', name, url) 'http://labix.org/python-dateutil',
result.append(( 'dateutil',
name,
url,
mod.__version__,
'1.0' '1.0'
)) ))
name = 'lxml' result.append(get_single(
url = 'http://lxml.de/' 'lxml',
mod = get_version_module('lxml.etree', name, url) 'http://lxml.de/',
result.append(( 'lxml.etree',
name,
url,
mod.__version__,
'3.1.0', '3.1.0',
)) ))
name = 'django-crispy-forms' result.append(get_single(
url = 'http://django-crispy-forms.readthedocs.org/' 'django-crispy-forms',
mod = get_version_module('crispy_forms', name, url) 'http://django-crispy-forms.readthedocs.org/',
result.append(( 'crispy_forms',
name,
url,
mod.__version__,
'1.4.0', '1.4.0',
)) ))
name = 'compressor' result.append(get_single(
url = 'https://github.com/django-compressor/django-compressor' 'compressor',
mod = get_version_module('compressor', name, url) 'https://github.com/django-compressor/django-compressor',
result.append(( 'compressor',
name,
url,
mod.__version__,
'1.5', '1.5',
)) ))
name = 'djangorestframework' result.append(get_single(
url = 'http://www.django-rest-framework.org/' 'djangorestframework',
mod = get_version_module('rest_framework', name, url) 'http://www.django-rest-framework.org/',
result.append(( 'rest_framework',
name,
url,
mod.__version__,
'3.3', '3.3',
)) ))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment