From: Alfredo Deza Date: Fri, 27 Jun 2014 16:26:34 +0000 (-0400) Subject: explain a bit what we are doing with the regex X-Git-Tag: v1.5.6~6^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F201%2Fhead;p=ceph-deploy.git explain a bit what we are doing with the regex Signed-off-by: Alfredo Deza --- diff --git a/vendor.py b/vendor.py index 375b308..e1c714d 100644 --- a/vendor.py +++ b/vendor.py @@ -54,6 +54,10 @@ def vendor_library(name, version, cmd=None): run(['rm', '-rf', vendor_src]) if path.exists(vendor_init): + # The following read/regex is done so that we can parse module metadata without the need + # to import it. Module metadata is defined as variables with double underscores. We are + # particularly insteresting in the version string, so we look into single or double quoted + # values, like: __version__ = '1.0' module_file = open(vendor_init).read() metadata = dict(re.findall(r"__([a-z]+)__\s*=\s*['\"]([^'\"]*)['\"]", module_file)) if metadata.get('version') != version: