This repository was archived by the owner on Jul 22, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello.py
More file actions
executable file
·62 lines (47 loc) · 1.29 KB
/
Copy pathhello.py
File metadata and controls
executable file
·62 lines (47 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python3
"""Hello World Multi Linguas.
Dependendo da lingua configurada no ambiente o programa exibe a mensagem
correspondente.
Como usar:
Tenha a variável LANG devidamente configurada ex:
export LANG=pt_BR
Ou informe atraves do CLI argument `--lang`
Ou o usuário terá que digitar.
Execução:
python3 hello.py
ou
./hello.py
"""
__version__ = "0.1.3"
__author__ = "Paulo Felix"
__license__ = "Unlicense"
import os
import sys
# print(f"{sys.argv=}")
arguments = {"lang": None, "count": 1,}
for arg in sys.argv[1:]:
# TODO: Tratar ValueError
key, value = arg.split("=")
key = key.lstrip("-").strip()
value = value.strip()
if key not in arguments:
print(f"Invalid Option`{key}`")
sys.exit()
arguments[key] = value
current_language = arguments["lang"]
if current_language is None:
# TODO: Usar repetição
if "LANG" in os.environ:
current_language = os.getenv("LANG")
else:
current_language = input("Choose Language")
current_language = current_language[:5]
msg = {
"en_US": "Hello, World!",
"pt_BR": "Olá, Mundo!",
"it_IT": "Ciao, Mondo!",
"es_SP": "Hola, Mundo!",
"fr_FR": "Bonjour Monde!"
}
# ordem Complexidade 0(n)
print(msg[current_language] * int(arguments["count"]))