Skip to content

Commit 78db6b8

Browse files
committed
black
1 parent 52fefb8 commit 78db6b8

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

scripts/generate_txconfig.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from pathlib import Path
1313

1414
# Replaces required to fix the default values set by 'tx add remote' command.
15-
# Add or remove
15+
# Add or remove
1616
TEXT_TO_REPLACE = {
1717
"2_": "2.",
1818
"3_": "3.",
@@ -38,20 +38,20 @@
3838
"xml_etree_": "xml.etree.",
3939
"xmlrpc_": "xmlrpc.",
4040
"xml_sax_": "xml.sax.",
41-
"xml_": "xml."
41+
"xml_": "xml.",
4242
}
4343

44+
4445
def parse_args():
4546
parser = argparse.ArgumentParser(description=__doc__)
4647
parser.add_argument(
4748
"--root-path",
4849
"-p",
4950
default=Path("."),
50-
help="Path to the translation files, and also the .tx/config (defaults to current directory)"
51+
help="Path to the translation files, and also the .tx/config (defaults to current directory)",
5152
)
5253
parser.add_argument(
53-
"tx_project",
54-
help="Slug of the Transifex project to query resources from"
54+
"tx_project", help="Slug of the Transifex project to query resources from"
5555
)
5656
return parser.parse_args()
5757

@@ -65,11 +65,19 @@ def reset_tx_config(txconfig: Path):
6565

6666
def populate_resources_from_remote(config_file: Path, tx_project: str):
6767
"""Add the remote resources from the Transifex project to .tx/config."""
68-
result = subprocess.run([
69-
"tx", "--config", str(config_file), "add", "remote",
70-
"--file-filter", "<lang>/<resource_slug>.<ext>",
71-
f"https://app.transifex.com/python-doc/{tx_project}/"
72-
], check=True)
68+
result = subprocess.run(
69+
[
70+
"tx",
71+
"--config",
72+
str(config_file),
73+
"add",
74+
"remote",
75+
"--file-filter",
76+
"<lang>/<resource_slug>.<ext>",
77+
f"https://app.transifex.com/python-doc/{tx_project}/",
78+
],
79+
check=True,
80+
)
7381
if result.returncode != 0:
7482
print("Failed to add the resources from remote:")
7583
print(result.stderr.strip())
@@ -91,9 +99,9 @@ def patch_config(txconfig: Path):
9199
line = line.replace("--", "/")
92100

93101
for pattern, replacement in TEXT_TO_REPLACE.items():
94-
if pattern in line:
95-
line = line.replace(pattern, replacement)
96-
break
102+
if pattern in line:
103+
line = line.replace(pattern, replacement)
104+
break
97105

98106
new_lines.append(line)
99107

@@ -102,6 +110,7 @@ def patch_config(txconfig: Path):
102110
txconfig.write_text(text + "\n", encoding="utf-8")
103111
print("Updated .tx/config with character substitutions")
104112

113+
105114
def main():
106115
args = parse_args()
107116
config_path = Path(".tx/config")

scripts/stats.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ def main() -> None:
2222
if lang_dir:
2323
pofiles_path = Path(lang_dir)
2424
else:
25-
language = os.environ.get("PYDOC_LANGUAGE")
26-
if not language:
27-
raise ValueError("Environment variable PYDOC_LANGUAGE is not set.")
28-
pofiles_path = Path(f"cpython/Doc/locales/{language}/LC_MESSAGES")
25+
language = os.environ.get("PYDOC_LANGUAGE")
26+
if not language:
27+
raise ValueError("Environment variable PYDOC_LANGUAGE is not set.")
28+
pofiles_path = Path(f"cpython/Doc/locales/{language}/LC_MESSAGES")
2929

3030
if not pofiles_path.exists():
3131
raise FileNotFoundError(f"Path does not exist: {pofiles_path}")

0 commit comments

Comments
 (0)