Remove unused code from lib/ansible/collections/ (#80712)

pull/80722/head^2
Matt Clay 1 year ago committed by GitHub
parent d12aa7f69c
commit 7eada15d1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,29 +0,0 @@
# (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import os
from ansible.module_utils.common.text.converters import to_bytes
B_FLAG_FILES = frozenset([b'MANIFEST.json', b'galaxy.yml'])
def is_collection_path(path):
"""
Verify that a path meets min requirements to be a collection
:param path: byte-string path to evaluate for collection containment
:return: boolean signifying 'collectionness'
"""
is_coll = False
b_path = to_bytes(path)
if os.path.isdir(b_path):
for b_flag in B_FLAG_FILES:
if os.path.exists(os.path.join(b_path, b_flag)):
is_coll = True
break
return is_coll

@ -1,16 +1,10 @@
# (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import os
from ansible.errors import AnsibleError
from ansible.cli.galaxy import with_collection_artifacts_manager
from ansible.galaxy.collection import find_existing_collections
from ansible.module_utils.common.text.converters import to_bytes
from ansible.utils.collection_loader import AnsibleCollectionConfig
from ansible.utils.collection_loader._collection_finder import _get_collection_name_from_path
from ansible.utils.display import Display
@ -27,36 +21,6 @@ def list_collections(coll_filter=None, search_paths=None, dedupe=True, artifacts
return collections
def list_valid_collection_paths(search_paths=None, warn=False):
"""
Filter out non existing or invalid search_paths for collections
:param search_paths: list of text-string paths, if none load default config
:param warn: display warning if search_path does not exist
:return: subset of original list
"""
if search_paths is None:
search_paths = []
search_paths.extend(AnsibleCollectionConfig.collection_paths)
for path in search_paths:
b_path = to_bytes(path)
if not os.path.exists(b_path):
# warn for missing, but not if default
if warn:
display.warning("The configured collection path {0} does not exist.".format(path))
continue
if not os.path.isdir(b_path):
if warn:
display.warning("The configured collection path {0}, exists, but it is not a directory.".format(path))
continue
yield path
@with_collection_artifacts_manager
def list_collection_dirs(search_paths=None, coll_filter=None, artifacts_manager=None, dedupe=True):
"""

Loading…
Cancel
Save