Skip to content

Commit

Permalink
Fix 180: Add some pycodestyle changes
Browse files Browse the repository at this point in the history
Signed-off-by: Cesar Lizarraga <[email protected]>
  • Loading branch information
calizarr committed Aug 5, 2024
1 parent 99ec769 commit e570ce8
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/python_inspector/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,34 +72,43 @@ def to_dict(self, generic_paths=False):
"resolution": self.resolution,
}


def pip_conf_get_index_urls() -> list:
"""
Returns a list of index_urls as provided by `pip config get`. If none, it returns an empty list.
Returns a list of index_urls as provided by `pip config get`.
If none, it returns an empty list.
"""

# Get index URLS from pip and split them into lists.
# Index URLs are split by whitespace
pip_index_url_cmd = ["/usr/bin/env", "python", "-m", "pip", "config", "get", "global.index-url"]
pip_extra_index_url_cmd = ["/usr/bin/env", "python", "-m", "pip", "config", "get", "global.extra-index-url"]
pip_index_url_cmd = ["/usr/bin/env", "python", "-m", "pip",
"config", "get", "global.index-url"]
pip_extra_index_url_cmd = ["/usr/bin/env", "python", "-m", "pip",
"config", "get", "global.extra-index-url"]
index_urls = subprocess.run(pip_index_url_cmd, capture_output=True)
if index_urls.returncode != 0:
index_urls = []
else:
index_urls = index_urls.stdout.decode("utf-8").split()
extra_index_urls = subprocess.run(pip_extra_index_url_cmd, capture_output=True)
extra_index_urls = subprocess.run(pip_extra_index_url_cmd,
capture_output=True)
if extra_index_urls.returncode != 0:
extra_index_urls = []
else:
extra_index_urls = extra_index_urls.stdout.decode("utf-8").split()

# Extract index urls from environment variables
pip_index_url_env = [] if os.getenv("PIP_INDEX_URL") is None else os.getenv("PIP_INDEX_URL").split()
pip_extra_index_url_env = [] if os.getenv("PIP_EXTRA_INDEX_URL") is None else os.getenv("PIP_EXTRA_INDEX_URL").split()
pip_index_url_env = [] if os.getenv("PIP_INDEX_URL") is None \
else os.getenv("PIP_INDEX_URL").split()
pip_extra_index_url_env = [] if os.getenv("PIP_EXTRA_INDEX_URL") is None \
else os.getenv("PIP_EXTRA_INDEX_URL").split()
pip_env_urls = pip_index_url_env + pip_extra_index_url_env

all_index_urls = [url for url in index_urls + extra_index_urls + pip_env_urls if url != ""]
all_index_urls = [url for url in index_urls + extra_index_urls +
pip_env_urls if url != ""]
return all_index_urls


def resolve_dependencies(
requirement_files=tuple(),
setup_py_file=None,
Expand Down

0 comments on commit e570ce8

Please sign in to comment.