#!/usr/bin/python """djLint · lint and reformat HTML templates.""" import os import sys import tempfile from concurrent.futures import ProcessPoolExecutor, as_completed from functools import partial from pathlib import Path from typing import Dict, List, Optional import click from click import echo from colorama import Fore, Style, colorama_text from tqdm import tqdm from .lint import lint_file from .output import print_output from .reformat import reformat_file from .settings import Config from .src import get_src @click.command(context_settings={"help_option_names": ["-h", "--help"]}) @click.argument( "src", type=click.Path( exists=True, file_okay=True, dir_okay=True, readable=True, allow_dash=True ), nargs=-1, required=True, metavar="SRC ...", ) @click.version_option(package_name="djlint") @click.option( "-e", "--extension", type=str, default="", help="File extension to check [default: html]", show_default=False, ) @click.option( "-i", "--ignore", type=str, default="", help='Codes to ignore. ex: "H014,H017"', show_default=False, ) @click.option( "--reformat", is_flag=True, help="Reformat the file(s).", ) @click.option( "--check", is_flag=True, help="Check formatting on the file(s).", ) @click.option( "--indent", type=int, help="Indent spacing. [default: 4]", show_default=False, ) @click.option( "--quiet", is_flag=True, help="Do not print diff when reformatting.", ) @click.option( "--profile", type=str, help="Enable defaults by template language. ops: django, jinja, nunjucks, handlebars, golang, angular, html [default: html]", ) @click.option( "--require-pragma", is_flag=True, help="Only format or lint files that starts with a comment with the text 'djlint:on'", ) @click.option( "--lint", is_flag=True, help="Lint for common issues. [default option]", ) @click.option( "--use-gitignore", is_flag=True, help="Use .gitignore file to extend excludes.", ) @click.option( "--warn", is_flag=True, help="Return errors as warnings.", ) @click.option( "--preserve-leading-space", is_flag=True, help="Attempt to preserve leading space on text.", ) @click.option( "--preserve-blank-lines", is_flag=True, help="Attempt to preserve blank lines.", ) @click.option( "--format-css", is_flag=True, help="Also format contents of