Skip to content

Commit

Permalink
Merge pull request #141 from marcelotrevisani/fb-change-color-default…
Browse files Browse the repository at this point in the history
…-messages

Change colours of the print message
  • Loading branch information
marcelotrevisani authored Jun 6, 2020
2 parents bd6e166 + 14bf272 commit 873774b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 25 deletions.
4 changes: 2 additions & 2 deletions grayskull/base/base_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ def _add_extra_section(self, maintainers: Optional[List] = None):
if not self["extra"]:
maintainers = maintainers if maintainers else [get_git_current_user()]
self["extra"]["recipe-maintainers"].add_items(maintainers)
prefix = f"{Fore.LIGHTBLACK_EX}\n - {Fore.LIGHTMAGENTA_EX}"
print_msg(f"{Fore.LIGHTBLACK_EX}Maintainers:{prefix}{prefix.join(maintainers)}")
prefix = f"\n - {Fore.LIGHTMAGENTA_EX}"
print_msg(f"Maintainers:{prefix}{prefix.join(maintainers)}")

def get_clean_yaml(self, recipe_yaml: CommentedMap) -> CommentedMap:
result = self._clean_yaml(recipe_yaml)
Expand Down
2 changes: 1 addition & 1 deletion grayskull/base/extra.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_git_current_user() -> str:
f" Exception: {err}"
)
print_msg(
f"{Fore.LIGHTBLACK_EX}Using default recipe maintainer:"
f"Using default recipe maintainer:"
f" {Fore.LIGHTMAGENTA_EX}AddYourGitHubIdHere"
)
return "AddYourGitHubIdHere"
11 changes: 4 additions & 7 deletions grayskull/license/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from typing import List, Optional, Union

import requests
from colorama import Fore
from rapidfuzz import process
from rapidfuzz.fuzz import token_set_ratio, token_sort_ratio
from requests import HTTPError
Expand Down Expand Up @@ -44,7 +43,7 @@ def get_all_licenses_from_spdx() -> List:
raise HTTPError(
f"It was not possible to communicate with spdx api.\n{response.text}"
)
print_msg(f"{Fore.LIGHTBLACK_EX}Recovering license info from spdx.org ...")
print_msg("Recovering license info from spdx.org ...")
return [
lic
for lic in response.json()["licenses"]
Expand Down Expand Up @@ -214,7 +213,7 @@ def search_license_api_github(
"""
github_url = _get_api_github_url(github_url, version)
log.info(f"Github url: {github_url} - recovering license info")
print_msg(f"{Fore.LIGHTBLACK_EX}Recovering license information from github...")
print_msg("Recovering license information from github...")

response = requests.get(url=github_url, timeout=10)
if response.status_code != 200:
Expand Down Expand Up @@ -277,7 +276,7 @@ def search_license_repo(
"""
git_url = re.sub(r"/$", ".git", git_url)
git_url = git_url if git_url.endswith(".git") else f"{git_url}.git"
print_msg(f"{Fore.LIGHTBLACK_EX}Recovering license info from repository...")
print_msg("Recovering license info from repository...")
tmp_dir = mkdtemp(prefix="gs-clone-repo-")
try:
check_output(_get_git_cmd(git_url, version, tmp_dir))
Expand Down Expand Up @@ -322,9 +321,7 @@ def get_license_type(path_license: str, default: Optional[str] = None) -> Option
if find_apache:
lic_type = find_apache[0]
return f"Apache-{lic_type[0]}.{lic_type[1]}"
print_msg(
f"{Fore.LIGHTBLACK_EX}Matching license file with database from Grayskull..."
)
print_msg("Matching license file with database from Grayskull...")
all_licenses = get_all_licenses()
licenses_text = list(map(itemgetter(1), all_licenses))
best_match = process.extract(
Expand Down
25 changes: 10 additions & 15 deletions grayskull/pypi/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def _get_sdist_metadata(self, sdist_url: str, name: str) -> dict:
self.files_to_copy.append(path_pkg)
log.debug(f"Unpacking {path_pkg} to {temp_folder}")
shutil.unpack_archive(path_pkg, temp_folder)
print_msg(f"{Fore.LIGHTBLACK_EX}Recovering information from setup.py")
print_msg("Recovering information from setup.py")
with PyPi._injection_distutils(temp_folder) as metadata:
metadata["sdist_path"] = temp_folder
return metadata
Expand Down Expand Up @@ -160,7 +160,7 @@ def _get_setup_cfg(source_path: str) -> dict:
from setuptools.config import read_configuration

log.debug(f"Started setup.cfg from {source_path}")
print_msg(f"{Fore.LIGHTBLACK_EX}Recovering metadata from setup.cfg")
print_msg("Recovering metadata from setup.cfg")
path_setup_cfg = list(Path(source_path).rglob("setup.cfg"))
if not path_setup_cfg:
return {}
Expand Down Expand Up @@ -239,12 +239,12 @@ def __fake_distutils_setup(*args, **kwargs):
try:
core.setup = __fake_distutils_setup
path_setup = str(path_setup)
print_msg(f"{Fore.LIGHTBLACK_EX}Executing injected distutils...")
print_msg("Executing injected distutils...")
PyPi.__run_setup_py(path_setup, data_dist)
if not data_dist or not data_dist.get("install_requires", None):
print_msg(
f"{Fore.LIGHTBLACK_EX}No data was recovered from setup.py."
f" Forcing to execute the setup.py as script"
"No data was recovered from setup.py."
" Forcing to execute the setup.py as script"
)
PyPi.__run_setup_py(path_setup, data_dist, run_py=True)
yield data_dist
Expand Down Expand Up @@ -520,12 +520,8 @@ def _get_metadata(self) -> dict:
license_file = os.path.basename(license_metadata.path)
self.files_to_copy.append(license_metadata.path)

print_msg(
f"{Fore.LIGHTBLACK_EX}License type: {Fore.LIGHTMAGENTA_EX}{license_name}"
)
print_msg(
f"{Fore.LIGHTBLACK_EX}License file: {Fore.LIGHTMAGENTA_EX}{license_file}"
)
print_msg(f"License type: {Fore.LIGHTMAGENTA_EX}{license_name}")
print_msg(f"License file: {Fore.LIGHTMAGENTA_EX}{license_file}")

all_requirements = self._extract_requirements(metadata)
all_requirements["host"] = solve_list_pkg_name(
Expand All @@ -536,10 +532,9 @@ def _get_metadata(self) -> dict:
)

def print_req(name, list_req: List):
prefix_req = f"{Fore.LIGHTBLACK_EX}\n - {Fore.LIGHTCYAN_EX}"
prefix_req = f"\n - {Fore.LIGHTCYAN_EX}"
print_msg(
f"{Fore.LIGHTBLACK_EX}{name} requirements:"
f"{prefix_req}{prefix_req.join(list_req)}"
f"{name} requirements:" f"{prefix_req}{prefix_req.join(list_req)}"
)

if all_requirements.get("build"):
Expand Down Expand Up @@ -626,7 +621,7 @@ def _get_pypi_metadata(self, name, version: Optional[str] = None) -> dict:
:param version: Package version
:return: Pypi metadata
"""
print_msg(f"{Fore.LIGHTBLACK_EX}Recovering metadata from pypi...")
print_msg("Recovering metadata from pypi...")
if version:
url_pypi = PyPi.URL_PYPI_METADATA.format(pkg_name=f"{name}/{version}")
else:
Expand Down

0 comments on commit 873774b

Please sign in to comment.