From 46dabbd7dfcf8e30d091ed01cc92da39ee1a864a Mon Sep 17 00:00:00 2001 From: Jaap Joris Vens Date: Mon, 30 Jan 2023 20:20:15 +0100 Subject: [PATCH 01/12] Update pre-commit config --- .pre-commit-config.yaml | 6 +++--- djhtml/modes.py | 5 +++-- setup.cfg | 7 ++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 64e47d7..a4cd384 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,13 +1,13 @@ repos: - repo: https://github.com/pycqa/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort - repo: https://github.com/psf/black - rev: 22.3.0 + rev: 22.12.0 hooks: - id: black - repo: https://github.com/pycqa/flake8 - rev: 4.0.1 + rev: 6.0.0 hooks: - id: flake8 diff --git a/djhtml/modes.py b/djhtml/modes.py index 074d627..d032a21 100644 --- a/djhtml/modes.py +++ b/djhtml/modes.py @@ -80,8 +80,9 @@ def parse(self): # to what it would have been with a # regular text token. - # If there is any OpenHard token in the set and current token is CloseHard - # then let's move back to OpenHard. + # If there is any OpenHard token in the + # set and current token is CloseHard then + # let's move back to OpenHard. if token.is_hard and any( t.is_hard and t.indents for t in stack ): diff --git a/setup.cfg b/setup.cfg index 1427ba0..d7f748a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -43,6 +43,7 @@ console_scripts = [flake8] max-line-length = 88 -select = C,E,F,W,B,B950 -extend-ignore = E203, E501 -extend-exclude = .nox +extend-ignore = E203 + +[isort] +profile = "black" From 56365d54d363d93291cd331cc237a2d82eaa7d85 Mon Sep 17 00:00:00 2001 From: Jaap Joris Vens Date: Mon, 30 Jan 2023 20:22:25 +0100 Subject: [PATCH 02/12] Support Python 3.11 --- noxfile.py | 2 +- setup.cfg | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 4d08777..0ff90eb 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,6 +1,6 @@ import nox -@nox.session(python=["3.6", "3.7", "3.8", "3.9", "3.10"]) +@nox.session(python=["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]) def tests(session): session.run("python", "-m", "unittest", "discover", "-v") diff --git a/setup.cfg b/setup.cfg index d7f748a..9eb56db 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,6 +16,7 @@ classifiers = Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+) Operating System :: OS Independent python_requires = '>=3.6' From 4a44f29a09d6a3188c136b31fbde781119dd509a Mon Sep 17 00:00:00 2001 From: Jaap Joris Vens Date: Mon, 30 Jan 2023 20:23:38 +0100 Subject: [PATCH 03/12] Remove `-i` and `-o` command line options The main use case of DjHTML is to modify files in-place. Therefore, the `-i` (`--in-place`) argument has been made the default and removed, leaving only a deprecation error. The `-o` (`--output-file`) argument has also been removed. Reading from standard input and writing to standard output is still supported by using "-" as the filename. By the same mechanism, writing the output to a different file is also still possible by using output redirection: djhtml - < input.html > output.html Since this is a backwards-incompatible change, the next release will increment the major version number. No changes have been made to the indentation algorithm. Closes #66 Closes #69 Closes #70 --- .pre-commit-hooks.yaml | 6 +- README.md | 19 ++-- djhtml/__main__.py | 250 ++++++++++++++++------------------------- djhtml/options.py | 53 +++++++++ 4 files changed, 159 insertions(+), 169 deletions(-) create mode 100644 djhtml/options.py diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 03d0157..0772121 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -1,6 +1,6 @@ - id: djhtml name: DjHTML - entry: djhtml -i + entry: djhtml types: [html] language: python language_version: python3 @@ -9,7 +9,7 @@ - id: djcss name: DjCSS - entry: djcss -i + entry: djcss types_or: [css, scss] language: python language_version: python3 @@ -18,7 +18,7 @@ - id: djjs name: DjJS - entry: djjs -i + entry: djjs types: [javascript] language: python language_version: python3 diff --git a/README.md b/README.md index 6d94ba3..e848e50 100644 --- a/README.md +++ b/README.md @@ -62,29 +62,24 @@ Install DjHTML with the following command: ## Usage After installation you can indent templates using the `djhtml` -command. The default is to read from standard in and to write the -indented output to standard out. To modify the source file in-place, -use the `-i` / `--in-place` option and specify a filename: +command: - $ djhtml -i template.html + $ djhtml template.html reindented template.html 1 template has been reindented. -Normally, the exit status of 0 means everything went well, regardless -of whether any files were changed. If any errors were encountered, the -exit status indicated the number of problematic files. However, when -the option `-c` / `--check` is used, the exit status is the number of -files that would have changed, but no changes are actually made. +An exit status of 0 means that everything went well, regardless of +whether any files were changed. When the option `-c` / `--check` is +used, the exit status is 1 when one or more files would have changed, +but no changes are actually made. All available options are: - `-h` / `--help`: show overview of available options -- `-i` / `--in-place`: modify files in-place - `-c` / `--check`: don't modify files; the exit status is the number of files that would have changed - `-q` / `--quiet`: don't print any output - `-t` / `--tabwidth`: set tabwidth (default is 4) -- `-o` / `--output-file`: write output to specified file ## `fmt:off` and `fmt:on` @@ -157,7 +152,7 @@ the default tabwidth, you change the `entry` point of these hooks: hooks: - id: djhtml # Use a tabwidth of 2 for HTML files - entry: djhtml -i -t 2 + entry: djhtml --tabwith 2 - id: djcss - id: djjs ``` diff --git a/djhtml/__main__.py b/djhtml/__main__.py index 1159477..16498d9 100644 --- a/djhtml/__main__.py +++ b/djhtml/__main__.py @@ -1,210 +1,152 @@ -import argparse -import sys -from pathlib import Path +""" +Entrypoint for all 4 command-line tools. Typical usage: -from . import modes + $ djhtml file1.html file2.html +Passing "-" as the filename will read from standard input and write to +standard output. Example usage: -def verify_changed(source, result): - """ - Verify that the source is either exactly equal to the result or - that the result has only changed by added or removed whitespace. + $ djhtml - < input.html > output.html +""" - """ - output_lines = result.split("\n") - changed = False - for line_nr, line in enumerate(source.split("\n")): - if line != output_lines[line_nr]: - changed = True - if line.strip() != output_lines[line_nr].strip(): - raise IndentationError("Non-whitespace changes detected. Core dumped.") +import sys +from pathlib import Path - return changed +from . import modes, options def main(): - """ - Entrypoint for all 4 command-line tools. Typical usage: - - $ djhtml -i file1.html file2.html + changed_files = 0 + unchanged_files = 0 + problematic_files = 0 - """ - target_extension = ".html" + suffixes = [".html"] Mode = modes.DjHTML if sys.argv[0].endswith("djtxt"): Mode = modes.DjTXT - target_extension = ".txt" + suffixes = [".txt"] if sys.argv[0].endswith("djcss"): Mode = modes.DjCSS - target_extension = ".css" + suffixes = [".css", ".scss"] if sys.argv[0].endswith("djjs"): Mode = modes.DjJS - target_extension = ".js" + suffixes = [".js"] - changed_files = 0 - unchanged_files = 0 - problematic_files = 0 + if len(options.input_filenames) > 1 and "-" in options.input_filenames: + sys.exit("I’m sorry Dave, I’m afraid I can’t do that.") - parser = argparse.ArgumentParser( - description=( - "DjHTML is a fully automatic template indenter that works with mixed" - " HTML/CSS/Javascript templates that contain Django or Jinja template" - " tags. It works similar to other code-formatting tools such as Black and" - " interoperates nicely with pre-commit. Full documentation can be found at" - " https://github.com/rtts/djhtml" - ), - ) - parser.add_argument( - "-i", "--in-place", action="store_true", help="modify files in-place" - ) - parser.add_argument("-c", "--check", action="store_true", help="don't modify files") - parser.add_argument("-q", "--quiet", action="store_true", help="be quiet") - parser.add_argument( - "-t", - "--tabwidth", - metavar="N", - type=int, - default=4, - help="tabwidth (default is 4)", - ) - parser.add_argument( - "-o", - "--output-file", - metavar="filename", - default="-", - help="output filename", - ) - parser.add_argument( - "input_filenames", - metavar="filenames", - nargs="*", - default=["-"], - help="input filenames (either paths or directories)", - ) - parser.add_argument("-d", "--debug", action="store_true", help=argparse.SUPPRESS) - args = parser.parse_args() - - if args.in_place and "-" in args.input_filenames: - sys.exit("I’m sorry Dave, I’m afraid I can’t do that") - - if len(args.input_filenames) > 1 and not args.in_place and not args.check: - sys.exit("Will not modify files in-place without -i option") - - for input_filename in _generate_files(args.input_filenames, target_extension): + for filename in _generate_filenames(options.input_filenames, suffixes): # Read input file try: - input_file = ( - sys.stdin if input_filename == "-" else open(input_filename, "r") - ) + input_file = sys.stdin if filename == "-" else open(filename, "r") source = input_file.read() except Exception as e: problematic_files += 1 - if not args.quiet: - print(f"Error opening {input_filename}: {e}", file=sys.stderr) - continue + _error(f"Cannot open {filename}: {e}") + finally: + input_file.close() # Indent input file try: - if args.debug: + if options.debug: print(Mode(source).debug()) sys.exit() - result = Mode(source).indent(args.tabwidth) + result = Mode(source).indent(options.tabwidth) except SyntaxError as e: problematic_files += 1 - if not args.quiet: - print( - f"Syntax error in {input_file.name}:" - f" {str(e) or e.__class__.__name__}", - file=sys.stderr, - ) + _error(f"Syntax error in {filename}: {str(e) or e.__class__.__name__}") continue except Exception: - print( - f"\nFatal error while processing {input_file.name}\n\n" + _error( + f"Fatal error while processing {filename}\n\n" " If you have time and are using the latest version, we\n" " would very much appreciate if you opened an issue on\n" - " https://github.com/rtts/djhtml/issues\n", - file=sys.stderr, + " https://github.com/rtts/djhtml/issues\n" ) raise - finally: - input_file.close() - - changed = verify_changed(source, result) - # Print to stdout and exit - if not args.in_place and not args.check and args.output_file == "-": - if not args.quiet: - print(result, end="") - sys.exit(1 if args.check and changed else 0) + changed = _verify_changed(source, result) + if changed: + changed_files += 1 + else: + unchanged_files += 1 # Write output file - if changed and args.check: - changed_files += 1 + if filename == "-": + if not options.check: + print(result, end="") elif changed: - output_filename = input_file.name if args.in_place else args.output_file try: - output_file = open(output_filename, "w") + output_file = open(filename, "w") output_file.write(result) output_file.close() - changed_files += 1 except Exception as e: + changed_files -= 1 problematic_files += 1 - if not args.quiet: - print(f"Error writing {output_filename}: {e}", file=sys.stderr) + _error(f"Error writing {filename}: {e}") continue - if not args.quiet: - print( - f"reindented {output_file.name}", - file=sys.stderr, - ) - else: - unchanged_files += 1 + _info(f"reindented {output_file.name}") # Print final summary - if not args.quiet: - s = "s" if changed_files != 1 else "" - have = "would have" if args.check else "have" if s else "has" - print( - f"{changed_files} template{s} {have} been reindented.", - file=sys.stderr, + s = "s" if changed_files != 1 else "" + have = "would have" if options.check else "have" if s else "has" + _info(f"{changed_files} template{s} {have} been reindented.") + if unchanged_files: + s = "s" if unchanged_files != 1 else "" + were = "were" if s else "was" + _info(f"{unchanged_files} template{s} {were} already perfect!") + if problematic_files: + s = "s" if problematic_files != 1 else "" + _info( + f"{problematic_files} template{s} could not be processed due to an error." ) - if unchanged_files: - s = "s" if unchanged_files != 1 else "" - were = "were" if s else "was" - print( - f"{unchanged_files} template{s} {were} already perfect!", - file=sys.stderr, - ) - if problematic_files: - s = "s" if problematic_files != 1 else "" - print( - f"{problematic_files} template{s} could not be processed due to an" - " error.", - file=sys.stderr, - ) - sys.exit(changed_files if args.check else problematic_files) + # Exit with appropriate exit status + if problematic_files: + sys.exit(1) + if options.check and changed_files: + sys.exit(1) + sys.exit(0) -def _generate_files(input_filenames, suffix): - for file_name in input_filenames: - if file_name == "-": - yield file_name +def _generate_filenames(paths, suffixes): + for filename in paths: + if filename == "-": + yield filename else: - file_path = Path(file_name) - if file_path.is_file(): - yield file_path - elif file_path.is_dir(): - yield from _generate_files_from_folder(file_path, suffix) - - -def _generate_files_from_folder(folder, suffix): - for file_path in folder.iterdir(): - if file_path.is_file() and file_path.suffix == suffix: - yield file_path - elif file_path.is_dir(): - yield from _generate_files_from_folder(file_path, suffix) + path = Path(filename) + if path.is_file(): + yield path + elif path.is_dir(): + yield from _generate_filenames_from_directory(path, suffixes) + + +def _generate_filenames_from_directory(directory, suffixes): + for path in directory.iterdir(): + if path.is_file() and path.suffix in suffixes: + yield path + elif path.is_dir(): + yield from _generate_filenames_from_directory(path, suffixes) + + +def _verify_changed(source, result): + output_lines = result.split("\n") + changed = False + for line_nr, line in enumerate(source.split("\n")): + if line != output_lines[line_nr]: + changed = True + if line.strip() != output_lines[line_nr].strip(): + raise IndentationError("Non-whitespace changes detected. Core dumped.") + return changed + + +def _info(msg): + if not options.quiet: + print(msg, file=sys.stderr) + + +def _error(msg): + _info(f"Error: {msg}") if __name__ == "__main__": diff --git a/djhtml/options.py b/djhtml/options.py new file mode 100644 index 0000000..f263102 --- /dev/null +++ b/djhtml/options.py @@ -0,0 +1,53 @@ +""" +Options set by command-line arguments. Usage: + + import options + print(f"Tabwidth is {options.tabwidth}") +""" + +import argparse +import sys + +parser = argparse.ArgumentParser( + description=( + "DjHTML is a fully automatic template indenter that works with mixed" + " HTML/CSS/Javascript templates that contain Django or Jinja template" + " tags. It works similar to other code-formatting tools such as Black and" + " interoperates nicely with pre-commit. Full documentation can be found at" + " https://github.com/rtts/djhtml" + ), +) +parser.add_argument( + "-c", + "--check", + action="store_true", + help="check indentation without modifying files", +) +parser.add_argument("-q", "--quiet", action="store_true", help="be quiet") +parser.add_argument( + "-t", + "--tabwidth", + metavar="N", + type=int, + default=4, + help="tabwidth (default is 4)", +) +parser.add_argument( + "input_filenames", + metavar="filename", + nargs="+", + help="input filenames (either paths or directories)", +) +parser.add_argument("-d", "--debug", action="store_true", help=argparse.SUPPRESS) +parser.add_argument("-i", "--in-place", action="store_true", help=argparse.SUPPRESS) + +# Parse arguments and assign attributes to self +self = sys.modules[__name__] +args = parser.parse_args(namespace=self) + +if self.in_place: + sys.exit( + "The -i (--in-place) argument has been deprecated as it's now the default. If" + " you have a custom pre-commit entry for DjHTML, remove the -i argument from it" + " and everything will continue to work as before." + ) From c19abf19f698ec0768c825a3cf259cb336c910bb Mon Sep 17 00:00:00 2001 From: Jaap Joris Vens Date: Tue, 31 Jan 2023 20:19:55 +0100 Subject: [PATCH 04/12] Exit with 123 when there are problematic files --- README.md | 3 ++- djhtml/__main__.py | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e848e50..7368287 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,8 @@ command: An exit status of 0 means that everything went well, regardless of whether any files were changed. When the option `-c` / `--check` is used, the exit status is 1 when one or more files would have changed, -but no changes are actually made. +but no changes are actually made. The exit status of 123 means that +there was an error while indenting one or more files. All available options are: diff --git a/djhtml/__main__.py b/djhtml/__main__.py index 16498d9..0f8e2d8 100644 --- a/djhtml/__main__.py +++ b/djhtml/__main__.py @@ -40,11 +40,11 @@ def main(): try: input_file = sys.stdin if filename == "-" else open(filename, "r") source = input_file.read() + input_file.close() except Exception as e: problematic_files += 1 - _error(f"Cannot open {filename}: {e}") - finally: - input_file.close() + _error(e) + continue # Indent input file try: @@ -103,7 +103,7 @@ def main(): # Exit with appropriate exit status if problematic_files: - sys.exit(1) + sys.exit(123) if options.check and changed_files: sys.exit(1) sys.exit(0) @@ -115,10 +115,10 @@ def _generate_filenames(paths, suffixes): yield filename else: path = Path(filename) - if path.is_file(): - yield path - elif path.is_dir(): + if path.is_dir(): yield from _generate_filenames_from_directory(path, suffixes) + else: + yield path def _generate_filenames_from_directory(directory, suffixes): From 3facd12a1db716c3e2542f0f929afcf670a044db Mon Sep 17 00:00:00 2001 From: Jaap Joris Vens Date: Tue, 31 Jan 2023 20:29:06 +0100 Subject: [PATCH 05/12] Update README --- README.md | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 7368287..8e84236 100644 --- a/README.md +++ b/README.md @@ -72,15 +72,8 @@ An exit status of 0 means that everything went well, regardless of whether any files were changed. When the option `-c` / `--check` is used, the exit status is 1 when one or more files would have changed, but no changes are actually made. The exit status of 123 means that -there was an error while indenting one or more files. - -All available options are: - -- `-h` / `--help`: show overview of available options -- `-c` / `--check`: don't modify files; the exit status is the number - of files that would have changed -- `-q` / `--quiet`: don't print any output -- `-t` / `--tabwidth`: set tabwidth (default is 4) +there was an error while indenting one or more files. All available +options are given by `djthml -h` / `djthml --help`. ## `fmt:off` and `fmt:on` From 917349194c2da209798da875319222ce03704e6a Mon Sep 17 00:00:00 2001 From: Jaap Joris Vens Date: Tue, 31 Jan 2023 20:33:15 +0100 Subject: [PATCH 06/12] Add Python 3.11 to workflow --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 020cfe3..74b3b53 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,6 +19,7 @@ jobs: - 3.8 - 3.9 - '3.10' + - '3.11' steps: - uses: actions/checkout@v2 From 1cdafb33f3dd27e205c59f80364eba34e4066a09 Mon Sep 17 00:00:00 2001 From: Jaap Joris Vens Date: Tue, 31 Jan 2023 20:45:16 +0100 Subject: [PATCH 07/12] Attempt to fix workflow --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 74b3b53..4d80350 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -34,4 +34,4 @@ jobs: python -m pip install --upgrade nox - name: Run tox targets for ${{ matrix.python-version }} - run: nox + run: nox --session tests-${{ matrix.python-version }} From 322c3191a3cea5234907a70866f658fde9b484d4 Mon Sep 17 00:00:00 2001 From: Jaap Joris Vens Date: Tue, 31 Jan 2023 21:08:10 +0100 Subject: [PATCH 08/12] Correctly close input files --- djhtml/__main__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/djhtml/__main__.py b/djhtml/__main__.py index 0f8e2d8..d72eacc 100644 --- a/djhtml/__main__.py +++ b/djhtml/__main__.py @@ -38,9 +38,11 @@ def main(): for filename in _generate_filenames(options.input_filenames, suffixes): # Read input file try: - input_file = sys.stdin if filename == "-" else open(filename, "r") - source = input_file.read() - input_file.close() + if filename == "-": + source = sys.stdin.read() + else: + with open(filename) as input_file: + source = input_file.read() except Exception as e: problematic_files += 1 _error(e) From 19c7a00d5572a0aaebd181d36a521379ae98ced6 Mon Sep 17 00:00:00 2001 From: Jaap Joris Vens Date: Tue, 31 Jan 2023 21:16:57 +0100 Subject: [PATCH 09/12] Fix bug writing output files --- djhtml/__main__.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/djhtml/__main__.py b/djhtml/__main__.py index d72eacc..e417182 100644 --- a/djhtml/__main__.py +++ b/djhtml/__main__.py @@ -74,20 +74,20 @@ def main(): unchanged_files += 1 # Write output file - if filename == "-": - if not options.check: - print(result, end="") - elif changed: - try: - output_file = open(filename, "w") - output_file.write(result) - output_file.close() - except Exception as e: - changed_files -= 1 - problematic_files += 1 - _error(f"Error writing {filename}: {e}") - continue - _info(f"reindented {output_file.name}") + if not options.check: + if filename == "-": + if not options.quiet: + print(result, end="") + elif changed: + try: + with open(filename, "w") as output_file: + output_file.write(result) + except Exception as e: + changed_files -= 1 + problematic_files += 1 + _error(e) + continue + _info(f"reindented {output_file.name}") # Print final summary s = "s" if changed_files != 1 else "" From 6a3a5adafb944f93714fb801ad6517d34bb8d15b Mon Sep 17 00:00:00 2001 From: Jaap Joris Vens Date: Tue, 31 Jan 2023 21:50:17 +0100 Subject: [PATCH 10/12] Cross operating system compatible way to determine mode --- djhtml/__main__.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/djhtml/__main__.py b/djhtml/__main__.py index e417182..a79e02b 100644 --- a/djhtml/__main__.py +++ b/djhtml/__main__.py @@ -20,17 +20,20 @@ def main(): unchanged_files = 0 problematic_files = 0 - suffixes = [".html"] - Mode = modes.DjHTML - if sys.argv[0].endswith("djtxt"): + # Determine mode based on script name + script_name = Path(sys.argv[0]) + if script_name.stem == "djtxt": Mode = modes.DjTXT suffixes = [".txt"] - if sys.argv[0].endswith("djcss"): + elif script_name.stem == "djcss": Mode = modes.DjCSS suffixes = [".css", ".scss"] - if sys.argv[0].endswith("djjs"): + elif script_name.stem == "djjs": Mode = modes.DjJS suffixes = [".js"] + else: + Mode = modes.DjHTML + suffixes = [".html"] if len(options.input_filenames) > 1 and "-" in options.input_filenames: sys.exit("I’m sorry Dave, I’m afraid I can’t do that.") From 2fc2413860ac42373c52e98853e5f569fe238843 Mon Sep 17 00:00:00 2001 From: Jaap Joris Vens Date: Tue, 31 Jan 2023 22:09:56 +0100 Subject: [PATCH 11/12] Improve deprecation message --- djhtml/options.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/djhtml/options.py b/djhtml/options.py index f263102..9fee2b1 100644 --- a/djhtml/options.py +++ b/djhtml/options.py @@ -47,7 +47,10 @@ if self.in_place: sys.exit( - "The -i (--in-place) argument has been deprecated as it's now the default. If" - " you have a custom pre-commit entry for DjHTML, remove the -i argument from it" - " and everything will continue to work as before." + """ +You have called DjHTML with the -i or --in-place argument which +has been deprecated as it's now the default. If you have a custom +pre-commit entry for DjHTML, remove the -i argument from it and +everything will continue to work as before. +""" ) From d8370771d244876c58999d40aa71ff61b3a8c7de Mon Sep 17 00:00:00 2001 From: Jaap Joris Vens Date: Tue, 31 Jan 2023 22:19:47 +0100 Subject: [PATCH 12/12] Remove the check for syntax errors as they are not raised anymore --- djhtml/__main__.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/djhtml/__main__.py b/djhtml/__main__.py index a79e02b..5368a55 100644 --- a/djhtml/__main__.py +++ b/djhtml/__main__.py @@ -57,10 +57,6 @@ def main(): print(Mode(source).debug()) sys.exit() result = Mode(source).indent(options.tabwidth) - except SyntaxError as e: - problematic_files += 1 - _error(f"Syntax error in {filename}: {str(e) or e.__class__.__name__}") - continue except Exception: _error( f"Fatal error while processing {filename}\n\n"