def vendor_library(name, version, cmd=None):
    this_dir = path.dirname(path.abspath(__file__))
    vendor_dest = path.join(this_dir, 'ceph_deploy/lib/vendor/%s' % name)
    vendor_init = path.join(vendor_dest, '__init__.py')
    vendor_src = path.join(this_dir, name)
    vendor_module = path.join(vendor_src, name)
    current_dir = os.getcwd()

    if path.exists(vendor_src):
        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:
            run(['rm', '-rf', vendor_dest])

    if not path.exists(vendor_dest):
        rc = run(['git', 'clone', name % 'git://git.ceph.com/%s'])
        if rc:
            print "%s: git clone failed using ceph.com url with rc %s, trying github.com" % (path.basename(__file__), rc)
            run(['git', 'clone', 'https://github.com/ceph/%s.git' % name])
        os.chdir(vendor_src)
        run(['git', 'checkout', version])
        if cmd:
            run(cmd)
        run(['mv', vendor_module, vendor_dest])
    os.chdir(current_dir)
dataset/ETHPy150Open ceph/ceph-deploy/vendor.py/vendor_library/swapped operands of `%`