X Tutup
Skip to content

Commit b72162a

Browse files
committed
feat: add custom command alias support per language
1 parent 9ad2582 commit b72162a

File tree

16 files changed

+103
-7
lines changed

16 files changed

+103
-7
lines changed

pyproject.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
[build-system]
2-
requires = ["setuptools>=64.0.0", "wheel"]
2+
requires = ["setuptools>=64.0.0", "wheel", "PyYAML>=6.0"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "universalpython"
77
version = "0.5.1-b.2"
8+
dynamic = ["scripts"]
89
authors = [
910
{name = "Saad Bazaz", email = "saadbazaz@hotmail.com"},
1011
]
@@ -41,9 +42,6 @@ packages = ["universalpython"]
4142
[tool.setuptools.package-data]
4243
universalpython = ["languages/**/*.yaml", "modes/*.py"]
4344

44-
[project.scripts]
45-
universalpython = "universalpython.universalpython:main"
46-
4745
[tool.semantic_release]
4846
version_toml = ["pyproject.toml:project.version"]
4947
upload_to_pypi = false

setup.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from setuptools import setup
2+
import os
3+
import yaml
4+
5+
LANGUAGES_DIR = os.path.join(os.path.dirname(__file__), 'universalpython', 'languages')
6+
7+
def get_aliases():
8+
aliases = []
9+
if not os.path.exists(LANGUAGES_DIR):
10+
return aliases
11+
for lang_dir in os.listdir(LANGUAGES_DIR):
12+
yaml_path = os.path.join(LANGUAGES_DIR, lang_dir, 'default.yaml')
13+
if not os.path.isfile(yaml_path):
14+
continue
15+
with open(yaml_path, encoding='utf-8') as f:
16+
data = yaml.safe_load(f)
17+
for alias in data.get('aliases', []):
18+
aliases.append(f'{alias}=universalpython.universalpython:main')
19+
return aliases
20+
21+
console_scripts = [
22+
'universalpython=universalpython.universalpython:main',
23+
'unipy=universalpython.universalpython:main',
24+
] + get_aliases()
25+
26+
setup(
27+
entry_points={
28+
'console_scripts': console_scripts,
29+
}
30+
)

universalpython/languages/cs/default.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
aliases:
2+
- "univerzálnípython"
3+
- "českýpython"
4+
15
letters:
26
start : "A"
37
end : "Ž"

universalpython/languages/de/default.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
aliases:
2+
- "universellpython"
3+
- "deutschpython"
4+
15
letters:
26
start : "a"
37
end : "z"

universalpython/languages/emoji/default.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
aliases:
2+
- "emojipython"
3+
14
letters:
25
start : "a"
36
end : "z"

universalpython/languages/fr/default.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
aliases:
2+
- "pythonuniversel"
3+
- "françaispython"
4+
15
letters:
26
start : "a"
37
end : "z"

universalpython/languages/ga/default.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
aliases:
2+
- "pythonuile"
3+
- "gaeilgepython"
4+
15
letters:
26
start : "a"
37
end : "z"

universalpython/languages/hi/default.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
aliases:
2+
- "hindipython"
3+
- "यूनिवर्सलपाइथन"
4+
- "हिंदीपाइथन"
5+
16
letters:
27
start : ""
38
end : ""

universalpython/languages/hu/default.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
aliases:
2+
- "univerzálispython"
3+
- "magyarpython"
4+
15
letters:
26
start : "a"
37
end : "z"

universalpython/languages/ko/default.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
aliases:
2+
- "유니버설파이썬"
3+
- "한국어파이썬"
4+
15
letters:
26
start : ""
37
end : ""

0 commit comments

Comments
 (0)
X Tutup