Skip to content

Commit

Permalink
Merge pull request #30 from seddonym/rendering-tweaks
Browse files Browse the repository at this point in the history
Tweak rendering
  • Loading branch information
seddonym committed Mar 25, 2019
2 parents eaebd5e + 3dcd001 commit 666e21f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/importlinter/application/rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ def render_report(report: Report) -> None:

for contract, contract_check in report.get_contracts_and_checks():
result_text = 'KEPT' if contract_check.kept else 'BROKEN'
output.print(f"{contract.name} {result_text}")
color_key = output.SUCCESS if contract_check.kept else output.ERROR
color = output.COLORS[color_key]
output.print(f"{contract.name} ", newline=False)
output.print(result_text, color=color)
output.new_line()

output.print(f"Contracts: {report.kept_count} kept, {report.broken_count} broken.")
Expand Down
6 changes: 3 additions & 3 deletions src/importlinter/contracts/independence.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def render_broken_contract(self, check: 'ContractCheck') -> None:
count = 0
for chains_data in check.metadata['invalid_chains']:
downstream, upstream = chains_data['downstream_module'], chains_data['upstream_module']
output.print(f"{downstream} is not allowed to import {upstream}:")
output.print_error(f"{downstream} is not allowed to import {upstream}:")
output.new_line()
count += len(chains_data['chains'])
for chain in chains_data['chains']:
Expand All @@ -94,11 +94,11 @@ def render_broken_contract(self, check: 'ContractCheck') -> None:
line_numbers = ', '.join(f'l.{n}' for n in direct_import['line_numbers'])
import_string = f"{importer} -> {imported} ({line_numbers})"
if first_line:
output.print(f"- {import_string}")
output.print_error(f"- {import_string}", bold=False)
first_line = False
else:
output.indent_cursor()
output.print(import_string)
output.print_error(import_string, bold=False)
output.new_line()

output.new_line()
4 changes: 2 additions & 2 deletions src/importlinter/contracts/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ def render_broken_contract(self, check: ContractCheck) -> None:
line_numbers = ', '.join(f'l.{n}' for n in direct_import['line_numbers'])
import_string = f"{importer} -> {imported} ({line_numbers})"
if first_line:
output.print(f"- {import_string}")
output.print_error(f"- {import_string}", bold=False)
first_line = False
else:
output.indent_cursor()
output.print(import_string)
output.print_error(import_string, bold=False)
output.new_line()

output.new_line()
Expand Down
2 changes: 1 addition & 1 deletion src/importlinter/domain/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def pop_imports(
importer=import_to_remove.importer.name,
imported=import_to_remove.imported.name)
if not import_details:
raise MissingImport('Ignored import {} not present in the graph.')
raise MissingImport(f'Ignored import {import_to_remove} not present in the graph.')
removed_imports.extend(import_details)
graph.remove_import(importer=import_to_remove.importer.name,
imported=import_to_remove.imported.name)
Expand Down

0 comments on commit 666e21f

Please sign in to comment.