Commit 3cc61745 authored by Johan Bakker's avatar Johan Bakker
Browse files

pylint fixes

parent f6110595
Loading
Loading
Loading
Loading
Loading

.pylintrc

0 → 100644
+17 −0
Original line number Diff line number Diff line
[MASTER]
init-hook="from pylint.config import find_pylintrc; import os, sys; sys.path.append(os.path.dirname(find_pylintrc()))"

disable=
    C0103, # Constant name doesn't conform to UPPER_CASE
    C0114, # missing-module-docstring
    C0115, # missing-class-docstring
    C0116, # Missing function or method docstring
    W0603, # Using the global statement
    R0903, # Too few public methods
    R0913, # Too many arguments
    R0914, # Too many locals
    W0703, # Catching too general exception Exception

[FORMAT]
max-line-length=120
+1 −0
Original line number Diff line number Diff line
"""Cache"""
config = {}
last_log_line = ""
log_repeat_log_msg_counter = 1
+14 −11
Original line number Diff line number Diff line
"""e2j2 main functions"""
import argparse
import json
import os
@@ -28,7 +29,7 @@ def repeat():
def arg_parse(program, description, version):
    arg_parser = argparse.ArgumentParser(prog=program, description=description)
    arg_parser.add_argument(
        "-v", "--version", action="version", version="%(prog)s {}".format(version)
        "-v", "--version", action="version", version=f"%(prog)s {version}"
    )
    arg_parser.add_argument(
        "-e",
@@ -125,7 +126,7 @@ def arg_parse(program, description, version):
        "--comment_end",
        type=str,
        help="Comment marker end (default: use marker set)",
    ),
    )
    arg_parser.add_argument(
        "--config-start", type=str, help="Config marker start (default: use marker set)"
    )
@@ -309,7 +310,7 @@ def configure(args):
def get_files(**kwargs):
    if kwargs["filelist"]:
        return kwargs["filelist"]
    else:

    return templates.find(
        searchlist=kwargs["searchlist"],
        j2file_ext=kwargs["extension"],
@@ -356,7 +357,7 @@ def run(config):
    for j2file in j2files:
        try:
            directory = os.path.dirname(j2file)
            filename = re.sub(r"{}$".format(extension), "", j2file)
            filename = re.sub(fr"{extension}$", "", j2file)

            if directory != old_directory:
                write(
@@ -380,13 +381,15 @@ def run(config):
                status = f"{colors.green}content"

                if config["stacktrace"]:
                    content += "\n\n%s" % traceback.format_exc()
                    content += f"\n\n{traceback.format_exc()}"

            if is_error and config["stderr"]:
                write(f"{colors.red}failed{colors.reset}{'':1}{content}\n")
            else:
                write(
                    f"{status:7}{'':1}{colors.green}=> writing{'':1}{colors.white}{basename(filename):35}{'':1}{colors.green}=>{'':1}"
                    f"{status:7}{'':1}{colors.green}"
                    "=> writing{'':1}{colors.white}{basename(filename):35}{'':1}{colors.green}"
                    "=>{'':1}"
                )

                if config["noop"]:
+1 −0
Original line number Diff line number Diff line
"""Constants"""
VERSION = "0.7.2"
ERROR = "** ERROR"
DESCRIPTION = "Parse jinja2 templates with enhanced JSON aware environment variables"
+14 −13
Original line number Diff line number Diff line
"display / terminal color handling functions"
import sys

from e2j2 import cache
@@ -19,27 +20,27 @@ class Colorize:
    white = WHITE


_colors = Colorize()
COLORS = Colorize()


def get_colors():
    return _colors
    return COLORS


def colorize():
    global _colors
    _colors = Colorize()
    global COLORS
    COLORS = Colorize()


def no_colors():
    global _colors
    _colors = Colorize()
    _colors.red = ""
    _colors.reset = ""
    _colors.yellow = ""
    _colors.green = ""
    _colors.lightgreen = ""
    _colors.white = ""
    global COLORS
    COLORS = Colorize()
    COLORS.red = ""
    COLORS.reset = ""
    COLORS.yellow = ""
    COLORS.green = ""
    COLORS.lightgreen = ""
    COLORS.white = ""


def write(msg):
@@ -51,7 +52,7 @@ def write(msg):
        sys.stderr.write(msg)
        cache.log_repeat_log_msg_counter = 0
    elif counter == print_at:
        sys.stderr.write("({}x) ".format(print_at) + msg)
        sys.stderr.write(f"({print_at}x) {msg}")
        cache.print_at += increment
        cache.log_repeat_log_msg_counter = 0

Loading