Skip to content

Commit

Permalink
Decolorize some of the info statements coming from the application
Browse files Browse the repository at this point in the history
Yellow - operating on the discovered information
Magenta - requires attention, not bad per se
Red - something bad has happened

Also, done cosmetic changes to the printed sentences, ain't noboody got
time to read novels.
  • Loading branch information
befeleme committed Oct 1, 2024
1 parent 0d4307c commit f775fec
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion pyp2spec/conf2spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def save_spec_file(config, output):
output = config.get_string("python_name") + ".spec"
with open(output, "w", encoding="utf-8") as spec_file:
spec_file.write(result)
click.secho(f"Spec file was saved successfully to '{output}'", fg="green")
click.secho(f"Spec file was saved successfully to '{output}'")
return output


Expand Down
23 changes: 11 additions & 12 deletions pyp2spec/pyp2conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,10 @@ def license(self, *, check_compliance=False, licenses_dict=None):

identifiers, expression = self.transform_to_spdx()
if not identifiers:
inspect_notice = "Inspect the project manually to find the license."
inspect_notice = "Inspect the project manually to find the license"
if expression:
err_string = f"WARNING: The found license `{expression}` is not a valid SPDX expression. " + inspect_notice
err_string = (f"WARNING: The found license expression '{expression}' "
"is not a valid SPDX expression. " + inspect_notice)
click.secho(err_string, fg="red")
else:
err_string = "WARNING: No license found. " + inspect_notice
Expand All @@ -208,11 +209,11 @@ def license(self, *, check_compliance=False, licenses_dict=None):
licenses_dict=licenses_dict
)
if checked_identifiers["bad"]:
err_string = "Found identifiers: `{0}` aren't allowed in Fedora."
err_string = "Found identifiers: '{0}' aren't allowed in Fedora."
click.secho(err_string.format(", ".join(checked_identifiers["bad"])), fg="red")
if checked_identifiers["good"]:
err_string = "Found identifiers: `{0}` are good for Fedora."
click.secho(err_string.format(", ".join(checked_identifiers["good"])), fg="green")
err_string = "Found identifiers: '{0}' are good for Fedora."
click.secho(err_string.format(", ".join(checked_identifiers["good"])), fg="yellow")
if not is_compliant:
return None
return expression
Expand Down Expand Up @@ -370,15 +371,14 @@ def create_config_contents(

# a package name was given as the `package`, look for it on PyPI
if is_package_name(package):
click.secho(f"Assuming '{package}' is a package name", fg="yellow")
click.secho(f"Querying PyPI for package '{package}'", fg="yellow")
pkg = PypiPackage(package, version=version, session=session)
click.secho(f"Querying PyPI for package '{package}'", fg="cyan")
# a URL was given as the `package`
else:
raise NotImplementedError("pyp2spec can't currently handle URLs.")

if version is None:
click.secho(f"Assuming PyPI --version={pkg.version}", fg="yellow")
click.secho(f"Assuming the latest version found on PyPI: '{pkg.version}'", fg="yellow")

if (license := pkg.license(check_compliance=compliant)) is not None:
contents["license"] = license
Expand All @@ -387,7 +387,7 @@ def create_config_contents(
contents["automode"] = True

if archful := pkg.is_archful():
click.secho("Package is archful - you may need to specify additional build requirements", fg="magenta")
click.secho("Package contains compiled extensions - you may need to specify additional build requirements", fg="magenta")

if python_alt_version is not None:
click.secho(f"Assuming build for Python: {python_alt_version}", fg="yellow")
Expand Down Expand Up @@ -415,11 +415,10 @@ def save_config(contents, output=None):
"""
if not output:
package = contents["python_name"]
output = f"./{package}.conf"
output = f"{package}.conf"
with open(output, "wb") as f:
click.secho(f"Saving configuration file to '{output}'", fg="yellow")
tomli_w.dump(contents, f, multiline_strings=True)
click.secho("Configuration file was saved successfully", fg="green")
click.secho(f"Configuration file was saved successfully to '{output}'")
return output


Expand Down
3 changes: 0 additions & 3 deletions pyp2spec/pyp2spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@
help="Provide custom output where spec file will be saved",
)
def main(**options):
click.secho("Generating configuration file", fg="cyan")
try:
config_file = create_config(options)
click.secho("Generating spec file", fg="cyan")
create_spec_file(config_file, options["spec_output"])
except (Pyp2specError, NotImplementedError) as exc:
click.secho(f"Fatal exception occurred: {exc}", fg="red")
sys.exit(1)
click.secho("Done", fg="green")


if __name__ == "__main__":
Expand Down

0 comments on commit f775fec

Please sign in to comment.