mirror of
https://github.com/StevenBlack/hosts.git
synced 2024-07-02 18:45:52 +02:00
Indeed, before this patch, no `# Title: XYZ` was describing our generated host file. This patch fixes that. Indeed, we now do the following: - If no extension is included we add: - `# Title: StevenBlack/hosts` - If exactly one extension is included we add: - `# Title: StevenBlack/hosts with the extension_name extension` - If more than one extension is included we add (in one line): - `# Title: StevenBlack/hosts with the extname1, extname2 and extname3 extensions` Please also note that I disable E203 (whitespace before ':') for flake8 at line 773. Since we use Black for code formatting let me redirect you to the documentation of Black which explain what I did. https://black.readthedocs.io/en/stable/the_black_code_style.html#slices : > Since E203 is not PEP 8 compliant, you should tell > Flake8 to ignore these warnings.
This commit is contained in:
parent
05dad7e657
commit
b93b427a6e
|
@ -769,7 +769,9 @@ def compress_file(input_file, target_ip, output_file):
|
|||
|
||||
if line.startswith(target_ip):
|
||||
if lines[lines_index].count(" ") < 9:
|
||||
lines[lines_index] += " " + line[target_ip_len : line.find("#")].strip()
|
||||
lines[lines_index] += (
|
||||
" " + line[target_ip_len : line.find("#")].strip() # noqa: E203
|
||||
)
|
||||
else:
|
||||
lines[lines_index] += "\n"
|
||||
lines.append(line[: line.find("#")].strip())
|
||||
|
@ -1032,6 +1034,29 @@ def write_opening_header(final_file, **header_params):
|
|||
+ "\n",
|
||||
)
|
||||
|
||||
if len(header_params["extensions"]) > 1:
|
||||
write_data(
|
||||
final_file,
|
||||
"# Title: StevenBlack/hosts with the {0} and {1} extensions\n".format(
|
||||
", ".join(header_params["extensions"][:-1]),
|
||||
header_params["extensions"][-1],
|
||||
),
|
||||
)
|
||||
else:
|
||||
write_data(
|
||||
final_file,
|
||||
"# Title: StevenBlack/hosts with the {0} extension\n".format(
|
||||
", ".join(header_params["extensions"])
|
||||
),
|
||||
)
|
||||
else:
|
||||
write_data(
|
||||
final_file,
|
||||
"# Title: StevenBlack/hosts\n".format(
|
||||
", ".join(header_params["extensions"])
|
||||
),
|
||||
)
|
||||
|
||||
write_data(
|
||||
final_file,
|
||||
(
|
||||
|
|
Loading…
Reference in New Issue
Block a user