run black/isort on Python scripts

This commit is contained in:
Damien Elmes 2021-04-14 18:22:02 +10:00
parent 01049b1289
commit c49d6ce49f
19 changed files with 73 additions and 52 deletions

View File

@ -21,12 +21,12 @@ COMMITS_SHALLOW_SINCE = {
"96e1358555c49905de89170f2b1102a7d8b6c4c2": "1598411535 +1000",
}
import os
import sys
import subprocess
import shutil
import re
import glob
import os
import re
import shutil
import subprocess
import sys
if os.getcwd() != os.path.abspath(os.path.dirname(__file__)):
print("Run this from the cargo/ folder")

View File

@ -2,14 +2,15 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os
import json
import re
import sys
import copy
import json
import os
import re
import shutil
import sys
from fluent.syntax import parse, serialize
from fluent.syntax.ast import Message, TextElement, Identifier, Pattern, Junk
from fluent.syntax.ast import Identifier, Junk, Message, Pattern, TextElement
# clone an existing ftl string as a new key
# eg:

View File

@ -6,12 +6,13 @@
Tool to extract core strings and keys from .ftl files.
"""
import os
import json
import glob
import json
import os
from fluent.syntax import parse
from fluent.syntax.serializer import serialize_element
from fluent.syntax.ast import Junk
from fluent.syntax.serializer import serialize_element
root = os.environ["BUILD_WORKSPACE_DIRECTORY"]
ftl_files = glob.glob(os.path.join(root, "ftl", "core", "*.ftl"), recursive=True)

View File

@ -6,17 +6,18 @@
Parse and re-serialize ftl files to get them in a consistent form.
"""
import os
import json
import glob
import sys
import difflib
import glob
import json
import os
import sys
from typing import List
from fluent.syntax import parse, serialize
from fluent.syntax.ast import Junk
from compare_locales.paths import File
from compare_locales import parser
from compare_locales.checks.fluent import ReferenceMessageVisitor
from compare_locales.paths import File
from fluent.syntax import parse, serialize
from fluent.syntax.ast import Junk
def check_missing_terms(path: str) -> bool:

View File

@ -1,10 +1,11 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os
import format
import sys
import glob
import os
import sys
import format
template_root = os.path.dirname(sys.argv[1])
template_files = glob.glob(os.path.join(template_root, "*", "*.ftl"), recursive=True)

View File

@ -5,14 +5,15 @@
# and copy source files to the translation repos. Requires access to the
# i18n repos to run.
import subprocess
from dataclasses import dataclass
import re
import os
import re
import subprocess
import sys
from typing import Optional, Tuple
import requests
from dataclasses import dataclass
from hashlib import sha256
from typing import Optional, Tuple
import requests
root = os.environ["BUILD_WORKSPACE_DIRECTORY"]
repos_bzl = os.path.join(root, "repos.bzl")

View File

@ -6,9 +6,10 @@
Tool to apply transform to an ftl string and its translations.
"""
import os
import json
import glob
import json
import os
from fluent.syntax import parse, serialize
from fluent.syntax.ast import Junk

View File

@ -6,16 +6,16 @@ import argparse
import glob
import logging
import os
import shutil
import sys
import re
import shutil
import subprocess
import sys
import pkginfo
from pip._internal.commands import create_command
from pip._vendor import pkg_resources
import pkginfo
def _create_nspkg_init(dirpath):
"""Creates an init file to enable namespacing"""

View File

@ -1,8 +1,9 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import sys
import os
import sys
import click
from piptools.scripts import compile

View File

@ -7,9 +7,7 @@ import re
import sys
import google.protobuf.descriptor
import pylib.anki._backend.backend_pb2 as pb
import stringcase
TYPE_DOUBLE = 1

View File

@ -18,6 +18,7 @@ def _build_info_path() -> str:
raise Exception("missing buildinfo.txt")
def _get_build_info() -> Dict[str, str]:
info = {}
with open(_build_info_path()) as file:
@ -29,6 +30,7 @@ def _get_build_info() -> Dict[str, str]:
return info
_buildinfo = _get_build_info()
buildhash=_buildinfo["STABLE_BUILDHASH"]
version=_buildinfo["STABLE_VERSION"]
buildhash = _buildinfo["STABLE_BUILDHASH"]
version = _buildinfo["STABLE_VERSION"]

View File

@ -1,5 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import platform
import time

View File

@ -1,5 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
from __future__ import annotations
import aqt

View File

@ -38,4 +38,4 @@ from . import stats
from . import studydeck
from . import synclog
from . import taglimit
from . import template
from . import template

View File

@ -18,7 +18,12 @@ outdata = re.sub(
outlines = []
qt_bad_types = [".connect(", "setStandardButtons", "setTextInteractionFlags", "setAlignment"]
qt_bad_types = [
".connect(",
"setStandardButtons",
"setTextInteractionFlags",
"setAlignment",
]
for line in outdata.splitlines():
for substr in qt_bad_types:
if substr in line:

View File

@ -32,10 +32,12 @@ for line in open(input_scss):
colors.setdefault(var, []).append(val)
with open(output_py, "w") as buf:
buf.write("""\
buf.write(
"""\
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
""")
"""
)
buf.write("# this file is auto-generated from _vars.scss\n")
for color, (day, night) in colors.items():
color = color.replace("-", "_").upper()

View File

@ -1,7 +1,10 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import sys, subprocess, os, difflib
import difflib
import os
import subprocess
import sys
clang_format = sys.argv[1]
workspace = os.environ.get("BUILD_WORKSPACE_DIRECTORY", "")

View File

@ -1,7 +1,8 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os, sys
import os
import sys
from pathlib import Path
nonstandard_header = {
@ -53,4 +54,4 @@ for dirpath, dirnames, fnames in os.walk("."):
found = True
if found:
sys.exit(1)
sys.exit(1)

View File

@ -3,7 +3,6 @@
import json
import sys
from typing import List
from typing import List, Literal, TypedDict
import stringcase
@ -63,12 +62,13 @@ def arg_kind(arg: Variable) -> str:
def map_args_to_real_names(args: List[Variable]) -> str:
return ("{" + ", ".join(
[f'"{arg["name"]}": args.{typescript_arg_name(arg)}' for arg in args]
return (
"{"
+ ", ".join(
[f'"{arg["name"]}": args.{typescript_arg_name(arg)}' for arg in args]
)
+ "}"
)
+ "}"
)
def get_args(args: List[Variable]) -> str:
@ -91,6 +91,7 @@ def typescript_arg_name(arg: Variable) -> str:
else:
return name
def module_names() -> str:
buf = "export enum ModuleName {\n"
for module in modules: