summaryrefslogtreecommitdiff
path: root/python/main.py
diff options
context:
space:
mode:
authormrdog233o5 <mr.dog233o5@gmail.com>2024-04-11 17:45:21 +0800
committermrdog233o5 <mr.dog233o5@gmail.com>2024-04-11 17:45:21 +0800
commitfea88e1f72780109f794305ea3d27571f12bb075 (patch)
treee76ed7f4d22a69fc8aada377b55a1f49000c9ff6 /python/main.py
parent97e5f5a00debc18ff538b7dd4da78be5221a8807 (diff)
added folder
Diffstat (limited to 'python/main.py')
-rw-r--r--python/main.py155
1 files changed, 155 insertions, 0 deletions
diff --git a/python/main.py b/python/main.py
new file mode 100644
index 0000000..17f516c
--- /dev/null
+++ b/python/main.py
@@ -0,0 +1,155 @@
+#!/usr/bin/env python3
+
+from sys import argv
+from python.stdlib import *
+
+"""
+map: Dictionary mapping single character keys to special characters to use for "fancy font".
+"""
+map = {
+ '`': '`',
+ '~': '`',
+ '1': '¡',
+ '!': '⁄',
+ '2': '™',
+ '@': '€',
+ '3': '£',
+ '#': '‹',
+ '4': '¢',
+ '$': '›',
+ '5': '∞',
+ '%': 'fi',
+ '6': '§',
+ '^': 'fl',
+ '7': '¶',
+ '&': '‡',
+ '8': '•',
+ '*': '°',
+ '9': 'ª',
+ '(': '·',
+ '0': 'º',
+ ')': '‚',
+ '-': '−',
+ '_': '—',
+ '=': '≠',
+ '+': '±',
+ 'q': 'œ',
+ 'Q': 'Œ',
+ 'w': '∑',
+ 'W': '„',
+ 'e': '´',
+ 'E': '´',
+ 'r': '®',
+ 'R': '‰',
+ 't': '†',
+ 'T': 'ˇ',
+ 'y': '¥',
+ 'Y': 'Á',
+ 'u': '¨',
+ 'U': '¨',
+ 'i': 'ˆ',
+ 'I': 'ˆ',
+ 'o': 'ø',
+ 'O': 'Ø',
+ 'p': 'π',
+ 'P': '∏',
+ '[': '“',
+ '{': '”',
+ ']': '‘',
+ '}': '’',
+ '\\': '«',
+ '|': '»',
+ 'a': 'å',
+ 'A': 'Å',
+ 's': 'ß',
+ 'S': 'Í',
+ 'd': '∂',
+ 'D': 'Î',
+ 'f': 'ƒ',
+ 'F': 'Ï',
+ 'g': '©',
+ 'G': '˝',
+ 'h': '˙',
+ 'H': '',
+ 'j': '∆',
+ 'J': 'Ô',
+ 'k': '˚',
+ 'K': '',
+ 'l': '¬',
+ 'L': 'Ò',
+ ';': '…',
+ ':': 'Ú',
+ 'z': 'Ω',
+ 'Z': '¸',
+ 'x': '≈',
+ 'X': '˛',
+ 'c': 'ç',
+ 'C': 'Ç',
+ 'v': '√',
+ 'V': '◊',
+ 'b': '∫',
+ 'B': 'ı',
+ 'n': '˜',
+ 'N': '˜',
+ 'm': 'µ',
+ 'M': 'Â',
+ ',': '≤',
+ '<': '≤',
+ '.': '≥',
+ '>': '˘',
+ '/': '÷',
+ '?': '¿'
+}
+
+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]
+
+ 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):
+ global in_data
+ aprintf("Mode selected: Reverse Mode")
+ for i in data:
+ try:
+ tmp = map[i]
+ except KeyError:
+ tmp = i
+ printf(tmp)
+
+if __name__ == '__main__':
+ in_data = keepasks("What is the data you want to transfer?", inputter=askinput)
+ main()