summaryrefslogtreecommitdiff
path: root/hacking/update_bundled.py
diff options
context:
space:
mode:
Diffstat (limited to 'hacking/update_bundled.py')
-rwxr-xr-xhacking/update_bundled.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/hacking/update_bundled.py b/hacking/update_bundled.py
new file mode 100755
index 0000000000..53b7a73a90
--- /dev/null
+++ b/hacking/update_bundled.py
@@ -0,0 +1,34 @@
+#!/usr/bin/python2 -tt
+
+import glob
+import json
+import os.path
+from distutils.version import LooseVersion
+
+from ansible.module_utils.urls import open_url
+
+basedir = os.path.dirname(__file__)
+
+for filename in glob.glob(os.path.join(basedir, '../lib/ansible/compat/*/__init__.py')):
+ if 'compat/tests' in filename:
+ # compat/tests doesn't bundle any code
+ continue
+
+ filename = os.path.normpath(filename)
+ with open(filename, 'r') as module:
+ for line in module:
+ if line.strip().startswith('_BUNDLED_METADATA'):
+ data = line[line.index('{'):].strip()
+ break
+ else:
+ print('WARNING: {0} contained no metadata. Could not check for updates'.format(filename))
+ continue
+ metadata = json.loads(data)
+ pypi_fh = open_url('https://pypi.python.org/pypi/{0}/json'.format(metadata['pypi_name']))
+ pypi_data = json.loads(pypi_fh.read())
+ if LooseVersion(metadata['version']) < LooseVersion(pypi_data['info']['version']):
+ print('UPDATE: {0} from {1} to {2} {3}'.format(
+ metadata['pypi_name'],
+ metadata['version'],
+ pypi_data['info']['version'],
+ 'https://pypi.python.org/pypi/{0}/'.format(metadata['pypi_name'])))