-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprompts.py
More file actions
63 lines (53 loc) · 1.91 KB
/
Copy pathprompts.py
File metadata and controls
63 lines (53 loc) · 1.91 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
63
# prompts.py
from config import REGIONS
from utils import normalize
def ask_choice(prompt: str, choices: list[str], allow_all=True) -> str:
while True:
print("\n" + prompt)
for i, c in enumerate(choices, start=1):
print(f" {i}. {c}")
if allow_all:
print(" 0. all")
raw = input("Pilihan: ").strip().lower()
if allow_all and raw in ["0", "all"]:
return "all"
if raw.isdigit():
idx = int(raw)
if 1 <= idx <= len(choices):
return choices[idx - 1]
if raw in [c.lower() for c in choices]:
return raw
print("❌ Pilihan tidak valid. Coba lagi.")
def ask_multi_states() -> list[str]:
print("\nPilih State (bisa banyak, pisahkan koma).")
print("Contoh: VIC,NSW atau ketik ALL")
print("Daftar:")
for code, name in REGIONS:
print(f" - {code} = {name}")
raw = input("State: ").strip()
if not raw or raw.lower() in ["all", "0"]:
return []
tokens = [normalize(x) for x in raw.split(",") if x.strip()]
valid = {normalize(c) for c, _ in REGIONS}
cleaned = [t for t in tokens if t in valid]
if not cleaned:
print("⚠️ Tidak ada state valid kebaca, dianggap ALL.")
return []
return cleaned
def ask_multi_jobtypes() -> list[str]:
print("\nPilih Job Type (bisa banyak, pisahkan koma).")
print("Ketik ALL untuk tanpa filter.")
print("Contoh umum: full time, part time, contract, casual, internship, permanent")
raw = input("Job type: ").strip()
if not raw or raw.lower() in ["all", "0"]:
return []
return [normalize(x) for x in raw.split(",") if x.strip()]
def ask_int(msg: str, default: int) -> int:
raw = input(f"{msg} (default {default}): ").strip()
if not raw:
return default
try:
v = int(raw)
return v if v > 0 else default
except:
return default