Skip to content

Commit 722732a

Browse files
committed
add --file and --output support
1 parent b0351d4 commit 722732a

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

sepunycoder

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#!/usr/bin/python3
22
import time
3-
import os
3+
import argparse
4+
45
def translte_to_cyrillic(text):
56
punycode_table = {
6-
'A': 'A', 'B': 'B', 'C': 'C', 'D': 'D', 'E': 'E', 'F': 'F', 'G': 'G', 'H': 'H', 'I': 'І', 'J': 'Ј', 'K': 'К', 'L': 'L', 'M': 'М', 'N': 'N', 'O': 'О', 'P': 'Р', 'Q': 'Ԛ', 'R': 'R', 'S': 'Ѕ', 'T': 'T', 'U': 'U', 'V': 'V', 'W': 'W', 'X': 'Х', 'Y': 'Y', 'Z': 'Z',
7-
'a': 'а', 'b': 'b', 'c': 'с', 'd': 'd', 'e': 'е', 'f': 'f', 'g': 'g', 'h': 'h', 'i': 'і', 'j': 'ј', 'k': 'k', 'l': 'l', 'm': 'm', 'n': 'n', 'o': 'о', 'p': 'р', 'q': 'ԛ', 'r': 'r', 's': 'ѕ', 't': 't', 'u': 'u', 'v': 'v', 'w': 'w', 'x': 'х', 'y': 'у', 'z': 'z'
8-
}
9-
7+
'A': 'A', 'B': 'B', 'C': 'C', 'D': 'D', 'E': 'E', 'F': 'F', 'G': 'G', 'H': 'H', 'I': 'І', 'J': 'Ј', 'K': 'К', 'L': 'L', 'M': 'М', 'N': 'N', 'O': 'О', 'P': 'Р', 'Q': 'Ԛ', 'R': 'R', 'S': 'Ѕ', 'T': 'T', 'U': 'U', 'V': 'V', 'W': 'W', 'X': 'Х', 'Y': 'Y', 'Z': 'Z',
8+
'a': 'а', 'b': 'b', 'c': 'с', 'd': 'd', 'e': 'е', 'f': 'f', 'g': 'g', 'h': 'h', 'i': 'і', 'j': 'ј', 'k': 'k', 'l': 'l', 'm': 'm', 'n': 'n', 'o': 'о', 'p': 'р', 'q': 'ԛ', 'r': 'r', 's': 'ѕ', 't': 't', 'u': 'u', 'v': 'v', 'w': 'w', 'x': 'х', 'y': 'у', 'z': 'z'
9+
}
1010
result = ''
1111
for char in text:
1212
if char.lower() in punycode_table:
@@ -16,21 +16,12 @@ def translte_to_cyrillic(text):
1616
result += punycode_table[char.lower()]
1717
else:
1818
result += char
19-
2019
return result
2120

22-
# Colors
2321
green_color = "\033[1;32m"
2422
end_color = "\033[0m"
25-
red_color = "\033[1;31m"
26-
blue_color = "\033[1;34m"
27-
yellow_color = "\033[1;33m"
28-
purple_color = "\033[1;35m"
29-
turquoise_color = "\033[1;36m"
30-
gray_color = "\033[1;37m"
3123

32-
# Print Welcome Banner
33-
banner=r'''{}
24+
banner = r'''{}
3425
______ _______ ______ _
3526
/ _____|_______|_____ \ | |
3627
( (____ _____ _____) ) _ ____ _ _ ____ ___ __| |_____ ____
@@ -45,14 +36,25 @@ for line in lines:
4536
print(line)
4637
time.sleep(0.08)
4738

48-
# Get user Input for Text to Translate
49-
user_input = input("🔓 Enter the text to translate to Cyrillic: ")
50-
user_input_https = input("🔗 Do you want to add \"https://\" protocol? (y/n): ")
51-
output_text = translte_to_cyrillic(user_input)
52-
if user_input_https == "y":
53-
output_text = "https://" + output_text
54-
print("👀 Translated text:", output_text)
55-
elif user_input_https == "n":
56-
print("👀 Translated text:", output_text)
39+
parser = argparse.ArgumentParser(description="Translate text to Cyrillic punycode.")
40+
parser.add_argument('--file', type=str, help="Input file containing the text to translate")
41+
parser.add_argument('--output', type=str, help="Output file to save the translated text")
42+
args = parser.parse_args()
43+
44+
if args.file:
45+
with open(args.file, 'r') as file:
46+
user_input = file.read()
47+
output_text = translte_to_cyrillic(user_input)
48+
else:
49+
user_input = input("🔓 Enter the text to translate to Cyrillic: ")
50+
user_input_https = input("🔗 Do you want to add \"https://\" protocol? (y/n): ")
51+
output_text = translte_to_cyrillic(user_input)
52+
if user_input_https == "y":
53+
output_text = "https://" + output_text
54+
55+
if args.output:
56+
with open(args.output, 'w') as file:
57+
file.write(output_text)
58+
print(f"👀 Translated text saved to {args.output}")
5759
else:
5860
print("👀 Translated text:", output_text)

0 commit comments

Comments
 (0)