Skip to content

Commit a51316e

Browse files
committed
update
1 parent 50dde37 commit a51316e

File tree

2 files changed

+27
-15
lines changed

2 files changed

+27
-15
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ repos:
22
- repo: local
33
hooks:
44
- id: style-print
5-
name: style-print
5+
name: ""
66
entry: "style-print 'This is highly experimental, please report any issues: https://github.com/python/python-docs-tr/issues' 'rUBI{y}'"
77
language: python
88
additional_dependencies: ["style-print"]
@@ -16,6 +16,7 @@ repos:
1616
entry: python .pre-commit-scripts/install_gettext.py
1717
language: system
1818
verbose: true
19+
pass_filenames: false
1920

2021
- id: lint
2122
name: Run sphinx-lint on .po files
@@ -28,6 +29,8 @@ repos:
2829
rev: v1.0.0
2930
hooks:
3031
- id: powrap
32+
name: Run powrap on .po files
33+
pass_filenames: false
3134

3235
- repo: https://github.com/psf/black
3336
rev: 23.1.0

.pre-commit-scripts/install_gettext.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env python3
22
import os
33
import sys
4-
import shlex
54
import shutil
65
import requests
76
import subprocess
@@ -14,24 +13,34 @@ def main():
1413
gettext_url = "https://github.com/vslavik/gettext-tools-windows/releases/download/v0.21.1/gettext-tools-windows-0.21.1.zip"
1514
gettext_path = os.path.join(os.environ["LOCALAPPDATA"], "Programs", "gettext-tools")
1615
gettext_zip = os.path.join(gettext_path, "gettext-tools.zip")
17-
16+
1817
try:
19-
subprocess.run(shlex.split(f"mkdir -p {gettext_path}", posix=False), shell=True, executable=powershell)
20-
21-
response = requests.get(gettext_url)
22-
with open(gettext_zip, "wb") as f:
23-
f.write(response.content)
24-
25-
with ZipFile(gettext_zip, "r") as zip:
26-
zip.extractall(gettext_path)
27-
28-
os.remove(gettext_zip)
29-
os.environ["PATH"] += os.pathsep + os.path.join(gettext_path, "bin")
18+
None if os.path.exists(gettext_path) else os.mkdir(gettext_path)
19+
20+
if not os.path.exists(os.path.join(gettext_path, "bin")):
21+
response = requests.get(gettext_url)
22+
with open(gettext_zip, "wb") as f:
23+
f.write(response.content)
24+
25+
with ZipFile(gettext_zip, "r") as zip:
26+
zip.extractall(gettext_path)
27+
28+
os.remove(gettext_zip) if os.path.exists(gettext_zip) else None
29+
30+
p = subprocess.run("$profile.CurrentUserCurrentHost", shell=True, executable=powershell, capture_output=True, text=True)
31+
with open(p.stdout.strip("\n"), "a+") as f:
32+
command = f"$Env:PATH += '{os.pathsep + os.path.join(gettext_path, 'bin')}'"
33+
f.seek(0)
34+
if command not in f.readlines():
35+
print("Adding gettext to PATH...")
36+
f.write(f"\n{command}")
37+
else:
38+
print("gettext is already in PATH")
3039

3140
except Exception as e:
3241
print(e)
3342
return 1
34-
43+
3544
else:
3645
return 0
3746

0 commit comments

Comments
 (0)