diff options
author | Lee Garrett <lgarrett@rocketjump.eu> | 2021-09-29 20:41:09 +0200 |
---|---|---|
committer | Lee Garrett <lgarrett@rocketjump.eu> | 2021-09-29 20:41:09 +0200 |
commit | 64aab4bd2d3ded02da538beb94a4a7fbf7781699 (patch) | |
tree | ba8539c275acd0c9cf9d9472e46e08e7768bce60 /lib/ansible/collections | |
parent | ddff31825e92941ec9bfa2aa3ef36e98a4b3b4a7 (diff) | |
download | debian-ansible-core-64aab4bd2d3ded02da538beb94a4a7fbf7781699.zip |
New upstream version 2.11.5
Diffstat (limited to 'lib/ansible/collections')
-rw-r--r-- | lib/ansible/collections/list.py | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/lib/ansible/collections/list.py b/lib/ansible/collections/list.py index a1d99017..c6af77a3 100644 --- a/lib/ansible/collections/list.py +++ b/lib/ansible/collections/list.py @@ -69,33 +69,34 @@ def list_collection_dirs(search_paths=None, coll_filter=None): collections = defaultdict(dict) for path in list_valid_collection_paths(search_paths): - b_path = to_bytes(path) - if os.path.isdir(b_path): - b_coll_root = to_bytes(os.path.join(path, 'ansible_collections')) + if os.path.basename(path) != 'ansible_collections': + path = os.path.join(path, 'ansible_collections') + + b_coll_root = to_bytes(path, errors='surrogate_or_strict') - if os.path.exists(b_coll_root) and os.path.isdir(b_coll_root): + if os.path.exists(b_coll_root) and os.path.isdir(b_coll_root): - if namespace is None: - namespaces = os.listdir(b_coll_root) - else: - namespaces = [namespace] + if namespace is None: + namespaces = os.listdir(b_coll_root) + else: + namespaces = [namespace] - for ns in namespaces: - b_namespace_dir = os.path.join(b_coll_root, to_bytes(ns)) + for ns in namespaces: + b_namespace_dir = os.path.join(b_coll_root, to_bytes(ns)) - if os.path.isdir(b_namespace_dir): + if os.path.isdir(b_namespace_dir): - if collection is None: - colls = os.listdir(b_namespace_dir) - else: - colls = [collection] + if collection is None: + colls = os.listdir(b_namespace_dir) + else: + colls = [collection] - for mycoll in colls: + for mycoll in colls: - # skip dupe collections as they will be masked in execution - if mycoll not in collections[ns]: - b_coll = to_bytes(mycoll) - b_coll_dir = os.path.join(b_namespace_dir, b_coll) - if is_collection_path(b_coll_dir): - collections[ns][mycoll] = b_coll_dir - yield b_coll_dir + # skip dupe collections as they will be masked in execution + if mycoll not in collections[ns]: + b_coll = to_bytes(mycoll) + b_coll_dir = os.path.join(b_namespace_dir, b_coll) + if is_collection_path(b_coll_dir): + collections[ns][mycoll] = b_coll_dir + yield b_coll_dir |