mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Make output more similar to black
This commit is contained in:
parent
b6ece5cc9e
commit
6b2c6d2991
1 changed files with 10 additions and 3 deletions
|
@ -191,31 +191,38 @@ class BlueprintApp:
|
||||||
tokens = tokenizer.tokenize(data)
|
tokens = tokenizer.tokenize(data)
|
||||||
|
|
||||||
tokenized_str = ""
|
tokenized_str = ""
|
||||||
for item in tokens:
|
for index, item in enumerate(tokens):
|
||||||
tokenized_str += str(item)
|
tokenized_str += str(item)
|
||||||
|
|
||||||
if data != tokenized_str:
|
if data != tokenized_str:
|
||||||
|
happened = "Would reformat"
|
||||||
|
|
||||||
if not opts.check:
|
if not opts.check:
|
||||||
file.seek(0)
|
file.seek(0)
|
||||||
file.truncate()
|
file.truncate()
|
||||||
file.write(tokenized_str)
|
file.write(tokenized_str)
|
||||||
|
happened = "Reformatted"
|
||||||
|
|
||||||
|
print(f"{Colors.BOLD}{happened} {file.name}{Colors.CLEAR}")
|
||||||
formatted_files += 1
|
formatted_files += 1
|
||||||
|
|
||||||
except PrintableError as e:
|
except PrintableError as e:
|
||||||
e.pretty_print(file.name, data, stream=sys.stderr)
|
e.pretty_print(file.name, data, stream=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
print("\n") # This actually prints two newlines
|
||||||
|
left_files = len(input_files) - formatted_files
|
||||||
|
|
||||||
if formatted_files == 0:
|
if formatted_files == 0:
|
||||||
print(f"{Colors.GREEN}{Colors.BOLD}Nothing to do.{Colors.CLEAR}")
|
print(f"{Colors.GREEN}{Colors.BOLD}Nothing to do.{Colors.CLEAR}")
|
||||||
elif opts.check:
|
elif opts.check:
|
||||||
print(
|
print(
|
||||||
f"{Colors.RED}{Colors.BOLD}{formatted_files} files would be reformatted.{Colors.CLEAR}"
|
f"{Colors.RED}{Colors.BOLD}{formatted_files} files would be reformatted, {left_files} would be left unchanged.{Colors.CLEAR}"
|
||||||
)
|
)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
print(
|
print(
|
||||||
f"{Colors.RED}{Colors.BOLD}Reformatted {formatted_files} files.{Colors.CLEAR}"
|
f"{Colors.RED}{Colors.BOLD}Reformatted {formatted_files} files, {left_files} were left unchanged.{Colors.CLEAR}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def cmd_lsp(self, opts):
|
def cmd_lsp(self, opts):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue