summaryrefslogtreecommitdiff
path: root/python/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/main.py')
-rw-r--r--python/main.py44
1 files changed, 4 insertions, 40 deletions
diff --git a/python/main.py b/python/main.py
index 17f516c..69c409c 100644
--- a/python/main.py
+++ b/python/main.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
from sys import argv
-from python.stdlib import *
+from stdlib import *
"""
map: Dictionary mapping single character keys to special characters to use for "fancy font".
@@ -102,52 +102,16 @@ map = {
}
def main():
- if len(argv) == 1: # no arguments
- transmode = keepasks("What is the transfer mode?(normal or reverse)", inputter=askinput)
- else:
- if "normal" not in argv[1] and "reverse" not in argv[1]:
- printerror("Please input normal or reverse")
- exit(1)
- else:
- transmode = argv[1]
+ translate(data=in_data)
- if "normal" in transmode.lower():
- transmode = 0
- normalMode(in_data)
- elif "reverse" in transmode.lower():
- transmode = 1
- reverseMode(in_data)
-
-
-def normalMode(data: str):
- """
- normalMode takes a string data as input, iterates through each character,
- looks up the corresponding substitution character in the map,
- and concatenates the substituted characters to build the output string out_data.
-
- It prints a message indicating normal mode was selected,
- performs the character substitution,
- and calls the outputter function to print the output string.
-
- This implements a simple letter substitution cipher in normal mode.
- """
- global in_data
- aprintf("Mode selected: Normal Mode")
- for i in data:
- try:
- tmp = list(map.keys())[list(map.values()).index(i)]
- except ValueError:
- tmp = i
- printf(tmp)
-
-def reverseMode(data: str):
+def translate(data: str):
global in_data
aprintf("Mode selected: Reverse Mode")
for i in data:
try:
tmp = map[i]
except KeyError:
- tmp = i
+ tmp = list(map.keys())[list(map.values()).index(i)]
printf(tmp)
if __name__ == '__main__':