Hayblock versions/0.1.0 Beta 2.5

import random # Various things needing a random thing import time # Time import datetime # Date and time import requests # Make HTTP requests import re # Regex import os # Generic py OS module stuff import shutil # File copy import json # Json stuff import urllib # More website things stuff
 * 1) Module imports

import hblang # "lang" module
 * 1) External file imports

code = open("code.txt","r").read.split("\n") logs = [] doing = 0 module = "" command = "" params = []
 * 1) Get code and define helper vars

showerrors = True errorcount = 0 ram = [] vars = {} lockedvars = [] imported = []
 * 1) Define more vars

posmodules = ["sys","var","math","tt","datetime","web","os","json","lang","coffee"]
 * 1) Define possible modules

def log(message): logs.append(f"At line {doing + 1}: {message}")
 * 1) Generic log and error functions

def error(message): log(f"Error at line {doing + 1}: {message}") global errorcount errorcount += 1 if showerrors: print(f"Error at line {doing + 1}:\n {message}")

str0to9 = ["0","1","2","3","4","5","6","7","8","9"]
 * 1) Is number checker

def isNumber(tocheck): hasdecimals = False for i in range(len(str(tocheck))): if not str(tocheck)[i] in str0to9: if str(tocheck)[i] == ".": hasdecimals = True else: return "nan" if hasdecimals: return "decimal" else: return "whole"

def getVar(varname): if varname in vars: return vars[varname] else: error(f"Attempted to get data in variable {varname}, which doesn't exist.")
 * 1) Get variable

def getType(tocheck): if str(tocheck)[0] == "\"":   return "string"  elif str(tocheck)[0] == "-":    return "varinput"  elif tocheck == "true" or tocheck == "false":    return "bool"  elif isNumber(tocheck) == "whole" or isNumber(tocheck) == "decimal":    return "number"  else:    return "invalid"
 * 1) Get type of variable

def tify(list): return ", ".join(list)
 * 1) Join list into commas

def param(num): # Use param(0) instead of params[0] try: if len(params[num]) < 1: error(f"Expected positional parameter {num + 1}, but nothing found.") else: return params[num] except IndexError: error(f"Expected positional parameter {num + 1}, but nothing found.")
 * 1) Get param/params

def funcReturn(message): print(f"A function returned: {message}") # Temporary
 * 1) Get what the function returned

def checkParam(wanted,tocheck): if getType(tocheck) == "string": if "string" in wanted: return tocheck[1:] else: error(f"Invalid data type given. Need {tify(wanted)}, but got {getType(tocheck)}.") elif getType(tocheck) == "bool": if "bool" in wanted: return tocheck else: error(f"Invalid data type given. Need {tify(wanted)}, but got {getType(tocheck)}.") elif getType(tocheck) == "number": if "number" in wanted: return tocheck else: error(f"Invalid data type given. Need {tify(wanted)}, but got {getType(tocheck)}.") elif getType(tocheck) == "varinput": return getVar(tocheck[1:]) else: error(f"Invalid data type given. Need {tify(wanted)}, but got {getType(tocheck)}.")
 * 1) Check parameter types and count

monthnames = { 1:"January", 2:"Febuary", 3:"March", 4:"April", 5:"May", 6:"June", 7:"July", 8:"August", 9:"September", 10:"October", 11:"November", 12:"December", } downames = { 0:"Monday", 1:"Tuesday", 2:"Wednesday", 3:"Thursday", 4:"Friday", 5:"Saturday", 6:"Sunday", }
 * 1) Utility constant dicts

datetimenow = datetime.datetime.now curcoffeetype = "espresso"
 * 1) Utility variables


 * 1) Start main loop

while len(code) > doing: if len(code[doing].replace(" ","")) < 1: log("A blank line has been skipped over.") doing += 1 elif f"{code[doing][0]}{code[doing][1]}" == "#-": log("A comment has been skipped over.") doing += 1 else: params = code[doing].split(".") try: module = params.pop(0) except IndexError: error("No module is found.") try: command = params.pop(0) except IndexError: error("No command is found.") if module in imported:

if module == "sys": if command == "print": print(checkParam(["string"],param(0))) elif module == "var": slr1 = checkParam(["string"],param(0)) if command == "create": if slr1 in vars: error(f"Variable {slr1} already exists.") else: vars[slr1] = "" elif command == "edit": if slr1 in lockedvars: error(f"Attempted to edit locked variable {slr1}.") elif slr1 in vars: vars[slr1] = checkParam(["string"],param(1)) else: error(f"Attempted to edit variable {slr1}, which doesn't exist.") elif command == "lock": if slr1 in lockedvars: error(f"Attempted to lock variable {slr1}, but it is already locked.") elif slr1 in vars: lockedvars.append(checkParam(["string"],param(0))) else: error(f"Attempted to lock variable {slr1}, but it doesn't exist.") elif command == "unlock": if slr1 in lockedvars: lockedvars.remove(checkParam(["string"],param(0))) elif slr1 in vars: error(f"Attempted to unlock variable {slr1}, but it is already unlocked.") else: error(f"Attempted to unlock variable {slr1}, but it doesn't exist.") elif command == "delete": if slr1 in lockedvars: error(f"Attempted to delete locked variable {slr1}.") elif slr1 in vars: del vars[slr1] else: error(f"Attempted to delete variable {slr1}, but it doesn't exist.") elif command == "list": if len(vars) < 1: error("No variables exist.") else: funcReturn(tify(vars)) elif command == "lockedlist": if len(lockedvars) < 1: error("No locked variables exist.") else: funcReturn(tify(lockedvars)) elif command == "type": funcReturn(getType(slr1)) elif command == "typecheck": funcReturn(checkParam(param(0),param(1))) elif command == "get": funcReturn(getVar(slr1)) elif command == "exists": funcReturn(str(slr1 in vars)) elif command == "islocked": funcReturn(str(slr1 in lockedvars))

elif module == "math": # Mostly generated by copilot slr1 = int(checkParam(["number"],param(0))) if command == "add": funcReturn(slr1 + checkParam(["number"],param(1))) elif command == "subtract": funcReturn(slr1 - checkParam(["number"],param(1))) elif command == "multiply": funcReturn(slr1 * checkParam(["number"],param(1))) elif command == "divide": funcReturn(slr1 / checkParam(["number"],param(1))) elif command == "modulo": funcReturn(slr1 % checkParam(["number"],param(1))) elif command == "quotient": funcReturn(slr1 // checkParam(["number"],param(1))) elif command == "power": funcReturn(slr1 ** checkParam(["number"],param(1))) elif command == "infinity": funcReturn("9" * 260) # Temporary elif command == "floor": funcReturn(math.floor(slr1)) elif command == "ceil": funcReturn(math.ceil(slr1)) elif command == "round": funcReturn(round(slr1)) elif command == "random": funcReturn(random.randint(slr1,checkParam(["number"],param(1)))) elif command == "truefalse": if random.randint(0,1) == 0: funcReturn("false") else: funcReturn("true") elif command == "pi": funcReturn(math.pi) elif command == "euler": funcReturn(math.e)       elif command == "tau": funcReturn(math.tau) elif command == "sin": funcReturn(math.sin(slr1)) elif command == "cos": funcReturn(math.cos(slr1)) elif command == "tan": funcReturn(math.tan(slr1)) elif command == "asin": funcReturn(math.asin(slr1)) elif command == "acos": funcReturn(math.acos(slr1)) elif command == "atan": funcReturn(math.atan(slr1)) elif command == "factorial": funcReturn(math.factorial(slr1)) elif command == "abs": funcReturn(math.fabs(slr1)) elif command == "deg": funcReturn(math.degrees(slr1)) elif command == "mean": funcReturn(math.mean(slr1)) elif command == "median": funcReturn(math.median(slr1)) elif command == "mode": funcReturn(math.mode(slr1)) elif command == "max": funcReturn(max(slr1)) elif command == "min": funcReturn(min(slr1)) elif command == "range": slr2 = [] for i in range(slr1): slr2.append(i + 1) funcReturn(slr2) elif command == "gcd": funcReturn(math.gcd(slr1,checkParam(["number"],param(1)))) elif command == "lcm": funcReturn(math.lcm(slr1,checkParam(["number"],param(1)))) elif command == "sqrt": funcReturn(math.sqrt(slr1)) elif command == "cbrt": # Square root but 3 instead of 2 funcReturn(math.cbrt(slr1)) elif command == "hypot": funcReturn(math.hypot(slr1,checkParam(["number"],param(1)))) elif command == "logar": if slr1 == "10": funcReturn(math.log10(checkParam(["number"],param(1)))) elif slr1 == "2": funcReturn(math.log2(checkParam(["number"],param(1)))) else: funcReturn(math.log(checkParam(["number"],param(1)),slr1)) elif module == "tt": # TT = text tools = string module, most of the module is github copilot generated slr1 = checkParam(["string"],param(0)) if command == "length": funcReturn(len(slr1)) elif command == "upper": funcReturn(slr1.upper) elif command == "lower": funcReturn(slr1.lower) elif command == "sub": funcReturn(slr1[checkParam(["number"],param(1)):checkParam(["number"],param(2))]) elif command == "replace": funcReturn(slr1.replace(checkParam(["string"],param(1)),checkParam(["string"],param(2)))) elif command == "upfirst": funcReturn(slr1.capitalize) elif command == "upwords": funcReturn(slr1.title) elif command == "wrap": while " " in slr1: slr1 = slr1.replace(" "," ") funcReturn(slr1) elif command == "split": funcReturn(slr1.split(checkParam(["string"],param(1)))) elif command == "count": funcReturn(slr1.count(checkParam(["string"],param(1)))) elif command == "startswith": funcReturn(slr1.startswith(checkParam(["string"],param(1)))) elif command == "endswith": funcReturn(slr1.endswith(checkParam(["string"],param(1)))) elif command == "includes": funcReturn(slr1.find(checkParam(["string"],param(1))) != -1) elif command == "index": funcReturn(slr1.find(checkParam(["string"],param(1)))) elif command == "uplow": if slr1.islower: funcReturn("lower") elif slr1.isupper: funcReturn("upper") else: funcReturn("mixed") elif command == "isnum": funcReturn(slr1.isnumeric) elif command == "isblank": funcReturn(len(slr1.replace(" ","")) < 1) elif command == "findlast": funcReturn(slr1.rfind(checkParam(["string"],param(1)))) elif command == "swapcase": funcReturn(slr1.swapcase) elif command == "reverse": funcReturn(slr1[::-1]) elif command == "search": # Regex funcReturn(re.search(checkParam(["string"],param(1)),slr1)) elif command == "findall": # Another regex funcReturn(re.findall(checkParam(["string"],param(1)),slr1)) elif command == "split": # Even another regex funcReturn(re.split(checkParam(["string"],param(1)),slr1)) elif command == "sub": # Last regex funcReturn(re.sub(checkParam(["string"],param(1)),checkParam(["string"],param(2)),slr1)) elif command == "hasmainkeys": # A predefined regex funcReturn(not str(re.search("[a-zA-Z0-9]",slr1)) == "None")

elif module == "datetime": # Also mostly generated by copilot if command == "wait": time.sleep(checkParam(["number"],param(0))) elif command == "now": funcReturn(datetime.datetime.now) elif command == "timestamp": funcReturn(time.time) elif command == "millennium": funcReturn(datetime.datetime.now.year // 1000) elif command == "century": funcReturn(datetime.datetime.now.year // 100) elif command == "decade": funcReturn(datetime.datetime.now.year // 10) elif command == "year": funcReturn(datetime.datetime.now.year) elif command == "month": funcReturn(datetime.datetime.now.month) elif command == "monthname": funcReturn(monthnames[datetime.datetime.now.month]) elif command == "week": funcReturn(datetime.datetime.now.isocalendar[1]) elif command == "dow": # Day of week funcReturn(datetime.datetime.now.weekday) elif command == "downame": funcReturn(downames[datetime.datetime.now.weekday]) elif command == "day": funcReturn(datetime.datetime.now.day) elif command == "hour": funcReturn(datetime.datetime.now.hour) elif command == "minute": funcReturn(datetime.datetime.now.minute) elif command == "second": funcReturn(datetime.datetime.now.second) elif command == "ms": funcReturn(datetime.datetime.now.microsecond) elif command == "format": funcReturn(datetime.datetime.now.strftime(checkParam(["string"],param(0)))) elif command == "with": funcReturn(datetime.datetime.now + datetime.timedelta(checkParam(["number"],param(0)))) elif command == "diff": funcReturn(datetime.datetime.now - datetime.timedelta(checkParam(["number"],param(0)))) elif command == "date": funcReturn(datetime.datetime.now.date) elif command == "time": funcReturn(datetime.datetime.now.time)

elif module == "web": slr1 = checkParam(["string"],param(0)) if command == "gethtml": slr2 = requests.get(slr1) funcReturn(slr2.text) elif command == "request": slr2 = requests.request(checkParam(["string"],param(1)),slr1) funcReturn(slr2.text) elif command == "extract": funcReturn(re.search("(?P https?://[^\s]+)",slr1).group("url")) elif command == "extractall": funcReturn(re.findall("(?P https?://[^\s]+)",slr1).group("url")) elif command == "urlencode": funcReturn(urllib.parse.quote(slr1)) elif command == "urldecode": funcReturn(urllib.parse.unquote(slr1)) elif command == "hasahref": # Another predefined regex, detects for a href tags funcReturn(not str(re.search("]*?\s+)?href=([\"'])(.*?)\\1",slr1)) == "None")

elif module == "os": slr1 = checkParam(["string"],param(0)) if command == "openfile": curfile1 = open(slr1) elif command == "readfile": funcReturn(curfile1.read) elif command == "editfile": if os.path.exists(slr1): curfile1.write(slr1) else: error(f"File {slr1} doesn't exist and can't be edited.") elif command == "createfile": if os.path.exists(slr1): error(f"File {slr1} already exists.") else: curfile1 = open(slr1,"w") elif command == "deletefile": os.remove(slr1) elif command == "closefile": curfile1.close elif command == "exists": funcReturn(os.path.exists(slr1)) elif command == "isblank": if os.path.isfile(slr1): funcReturn(os.path.getsize(slr1) == 0) else: error(f"File {slr1} doesn't exist.") elif command == "iswritable": curfile1.writable elif command == "os": funcReturn(os.name) elif command == "cwd": funcReturn(os.getcwd) elif command == "exit": log("Exiting...") exit elif command == "changedir": os.chdir(slr1) elif command == "makedir": os.mkdir(slr1) elif command == "deldir": os.rmdir(slr1) elif command == "listdir": funcReturn(os.listdir(slr1)) elif command == "renamefile": os.rename(slr1,checkParam(["string"],param(1))) elif command == "copyfile": shutil.copyfile(slr1,checkParam(["string"],param(1))) elif module == "json": # Entirely copilot generated, so there might be duplicated/weirdly placed functions, this will be reviewed and corrected later on       slr1 = checkParam(["string"],param(0)) if command == "load": funcReturn(json.loads(slr1)) elif command == "dump": funcReturn(json.dumps(slr1)) elif command == "pretty": funcReturn(json.dumps(slr1,indent=2)) elif command == "get": funcReturn(json.loads(slr1)[checkParam(["string"],param(1))]) elif command == "set": slr2 = json.loads(slr1) slr2[checkParam(["string"],param(1))] = checkParam(["string"],param(2)) funcReturn(json.dumps(slr2)) elif command == "del": slr2 = json.loads(slr1) del slr2[checkParam(["string"],param(1))] funcReturn(json.dumps(slr2)) elif command == "keys": funcReturn(json.loads(slr1).keys) elif command == "values": funcReturn(json.loads(slr1).values) elif command == "items": funcReturn(json.loads(slr1).items) elif command == "len": funcReturn(len(json.loads(slr1))) elif command == "type": funcReturn(type(json.loads(slr1))) elif command == "isarray": funcReturn(isinstance(json.loads(slr1),list)) elif command == "isobject": funcReturn(isinstance(json.loads(slr1),dict)) elif command == "isstring": funcReturn(isinstance(json.loads(slr1),str)) elif command == "isnumber": funcReturn(isinstance(json.loads(slr1),int)) elif command == "isbool": funcReturn(isinstance(json.loads(slr1),bool)) elif command == "isnull": funcReturn(json.loads(slr1) == None) elif command == "isempty": funcReturn(json.loads(slr1) == "") elif command == "isnotempty": funcReturn(json.loads(slr1) != "") elif command == "isnotnull": funcReturn(json.loads(slr1) != None)

elif module == "lang": # Use slr1 (single line ram) when a parameter is required for every function in the module! if command == "translate": funcReturn(hblang.translateLangToLang(checkParam(["string"],param(0)),checkParam(["string"],param(1)),checkParam(["string"],param(2)))) elif command == "getlang": funcReturn(hblang.getLang(checkParam(["string"],param(0)))) elif command == "name": funcReturn(hblang.codeToLang(checkParam(["string"],param(0)))) elif command == "code": funcReturn(hblang.langToCode(checkParam(["string"],param(0)))) elif command == "accent": funcReturn(hblang.nameToAccent(checkParam(["string"],param(0)))) elif command == "whatis": funcReturn(hblang.accentToName(checkParam(["string"],param(0)))) elif command == "langs": funcReturn(hblang.allLangs) elif command == "accents": funcReturn(hblang.allAccents) elif command == "grammar": slr1 = hblang.grammar(checkParam(["string"],param(0)),checkParam(["string"],param(1))) slr2 = checkParam(["string"],param(0)) if slr1 == "unk": error(f"Grammar function {slr2} doesn't exist.") else: funcReturn(slr1) elif command == "currentlang": funcReturn(hblang.currentLang)

elif module == "coffee": # Entirely a joke if command == "makecoffee": if curcoffeetype.startswith("a") or curcoffeetype.startswith("e") or curcoffeetype.startswith("i") or curcoffeetype.startswith("o") or curcoffeetype.startswith("u"): print(f"Okay, making an {curcoffeetype} coffee, please wait a bit...") else: print(f"Okay, making a {curcoffeetype} coffee, please wait a bit...") time.sleep(random.randint(2,6)) print("Coffee's done! \u2615") elif command == "changecoffee": slr1 = input("What type of coffee do you like now? ") if slr1 == curcoffeetype: print(f"You already like {curcoffeetype} coffee.") else: print(f"Changed liked coffee from {curcoffeetype} to {slr1}.") curcoffeetype = slr1 elif command == "drinkcoffee": print(f"You drank {curcoffeetype} coffee! \u2615") elif command == "sipcoffee": print("*awkward sounds intensify*") elif command == "throwcoffee": print(f"You threw away your cup of {curcoffeetype} coffee because it wasn't yummy at all. \U0001F5D1") elif command == "maketea": print("Hey! This is the coffee module! You can't make tea here! And no there's no tea module lol") elif command == "coffeeinfo": print(f"You like {curcoffeetype} coffee.") elif command == "boilcoffee": print("\U0001F4A6\U0001F4A6\U0001F4A6\U0001F4A6\U0001F4A6\U0001F4A6\U0001F4A5\U0001F4A5 What the hell??? The coffee exploded! Oh no! This is an absolute disaster! Well, looks like I boiled it too much.") elif command == "boilerplate": print("Umm...excuse me? A coffee is not a plate. And it's not for testing.") elif command == "coffeecount": print("Loading...") slr1 = "\u2591" * 40 slr1 = f"{slr1}\n" time.sleep(random.randint(1,3)) print(slr1 * 6) print("You have a bazillion coffees. Here's a picture of your garage full of cooki- i mean coffees. Also, each dot is a cup of coffee.") elif command == "puticeintocoffee": print("*ice melts*\U0001F9CA\U0001F4A7 *extremely loud SHOOOOOOO*\U0001F50A\U0001F4A8 *your eardrums blast*\U0001F442\U0001F32B") elif command == "makecafe": print("Sorry, we're not frenc- uh spanis- uh catala- uh galic- portugue- ok im done") elif command == "makelatte": print("What? Latte is totally not a coffee! Like totally! Just look at the wikipedia page! You can't? Well, I'll just show it here!\n\n") elif command == "putmilkintocoffee": print("You won't get a latte. It's not that easy. \U0001F4AB") elif command == "makeespresso": print("You made an espresso. \U0001F4AC And that is the best coffee you've ever had. \U0001F4AC You will be happy. \U0001F4AC Okay, you're done. \U0001F4AC\nThat is completely generated by GitHub Copilot so it's a little odd if you compare it to the other coffee module functions!") elif command == "pourwaterintocoffee": print("You poured water into your coffee. \U0001F4A6 WHAT THE HEL-\n\n        ...\n\n     \U0001F32B\n     \u2615") elif command == "coffee": print(".coffee") elif command == "koffie": print(".?") elif command == "coffeeguide": print("\n| by coffee publishing |\n|                     |\n| How to make...       |\n|   DELICIOUS COFFEES! |\n|                      |\n|  The ultimate guide  |\n| to brew the tastiest |\n|  coffee of all time! |\n|                      |\n|By Mr.Coffeeman Coffee|\n|Printed using good ink|\n|                      |\n| price: 999999999999$ |\n\n\n\n| Chapter 1.           |\n|     A basic coffee   |\n|                      |\n|   Welcome! This book |\n|will teach you about  |\n|the most delicious    |\n|coffee recipes ever,  |\n|and just how to brew  |\n|good coffees overall. |\n|So, let's make a basic|\n|coffee.   Step 1. idk |\n|                      |\n| Coffees good! Page 1 |\n") elif command == "lowercoffee": print("NO! YOU CAN NOT DO THAT! COFFEE MUST BE AT THE TOP! THE KING OF THE DRINKS! oh wait, you mean turning the word coffee lowercase?....oh.") elif command == "importcoffee": print("okay, importing coffee module...FATAL ERROR MODULE COFFEE NOT FOUND 404 404 404 404 404 404 404 404") elif command == "eeffoc": slr1 = "    " * 164 slr2 = "    " * 237 print(f"Cof{slr1}fff{slr1}ffeeeee!!!") elif command == "debug": print("Coffee does not have the ability to debug your broken code.") elif command == "drinkwater": print("Drinking water is free. You drank water. ikr") elif command == "eatpizza": print("No; you can't eat pizza. You can only drink it. *awkward noises*") elif command == "hayblock": print("I'm pretty sure hay infused with coffee doesn't taste very good :/") elif command == "spillcoffee": print("shhh") elif command == "whatshouldido": print("Pray the coffee gods.") elif command == "makemorecoffee": print("You made -1 coffees. \U0001F4AC") elif module == "import": if command in imported: error(f"Module {command} can't be imported again because it is already imported.") elif command in posmodules: imported.append(command) else: error(f"Module {command} can't be imported because it doesn't exist.") elif module in posmodules: error(f"Module {module} is not imported.") else: error(f"Module {module} is not imported and doesn't exist.") doing += 1 : import requests

def translateLangToLang(text,fromLang,toLang): url = f"https://translate.googleapis.com/translate_a/single?client=gtx&sl={fromLang}&tl={toLang}&dt=t&q={text}" response = requests.get(url) response = response.json return response[0][0][0]

def getLang(text): url = f"https://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl=en&dt=t&q={text}" response = requests.get(url) response = response.json return response[2]

currentLang = "en"

langcodes = { "af":"Afrikaans", "sq":"Albanian", "am":"Amharic", "ar":"Arabic", "hy":"Armenian", "az":"Azerbaijani", "eu":"Basque", "be":"Belarusian", "bn":"Bengali", "bs":"Bosnian", "bg":"Bulgarian", "ca":"Catalan", "ceb":"Cebuano", "ny":"Chichewa", "zh-CN":"Chinese (Simplified)", "zh-TW":"Chinese (Traditional)", "co":"Corsican", "hr":"Croatian", "cs":"Czech", "da":"Danish", "nl":"Dutch", "en":"English", "eo":"Esperanto", "et":"Estonian", "tl":"Filipino", "fi":"Finnish", "fr":"French", "fy":"Frisian", "gl":"Galician", "ka":"Georgian", "de":"German", "el":"Greek", "gu":"Gujarati", "ht":"Haitian Creole", "ha":"Hausa", "haw":"Hawaiian", "iw":"Hebrew", "hi":"Hindi", "hmn":"Hmong", "hu":"Hungarian", "is":"Icelandic", "ig":"Igbo", "id":"Indonesian", "ga":"Irish", "it":"Italian", "ja":"Japanese", "jw":"Javanese", "kn":"Kannada", "kk":"Kazakh", "km":"Khmer", "ko":"Korean", "ku":"Kurdish (Kurmanji)", "ky":"Kyrgyz", "lo":"Lao", "la":"Latin", "lv":"Latvian", "lt":"Lithuanian", "lb":"Luxembourgish", "mk":"Macedonian", "mg":"Malagasy", "ms":"Malay", "ml":"Malayalam", "mt":"Maltese", "mi":"Maori", "mr":"Marathi", "mn":"Mongolian", "my":"Myanmar (Burmese)", "ne":"Nepali", "no":"Norwegian", "ps":"Pashto", "fa":"Persian", "pl":"Polish", "pt":"Portuguese", "ma":"Punjabi", "ro":"Romanian", "ru":"Russian", "sm":"Samoan", "sr":"Serbian", "st":"Sesotho", "sn":"Shona", "sd":"Sindhi", "si":"Sinhala", "sk":"Slovak", "sl":"Slovenian", "so":"Somali", "es":"Spanish", "su":"Sundanese", "sw":"Swahili", "sv":"Swedish", "tg":"Tajik", "ta":"Tamil", "te":"Telugu", "th":"Thai", "tr":"Turkish", "uk":"Ukrainian", "ur":"Urdu", "uz":"Uzbek", "vi":"Vietnamese", "cy":"Welsh", "xh":"Xhosa", "yi":"Yiddish", "yo":"Yoruba", "zu":"Zulu" }

def codeToLang(code): try: return langcodes[code] except KeyError: return "unk"

def langToCode(lang): for key, value in langcodes.items: if value == lang: return key return "Unknown"

accents = { "Acute":"◌́ ", "Grave":"◌̀ ", "Circ":"◌̂ ", "Tilde":"◌̃ ", "Macr":"◌̄ ", "Breve":"◌̆ ", "Dot":"◌̇ ", "Dblac":"◌̈ ", "Ring":"◌̊ ", "Cedil":"◌̌ ", "Ogon":"◌̋ ", }

def nameToAccent(name): try: return accents[name] except KeyError: return "unk"

def accentToName(accent): for key, value in accents.items: if value == accent: return key return "Unknown"

allLangs = langcodes.values allAccents = accents.keys
 * 1) Both of these returns tuple-like things for now, will fix later

def grammarIndefArticle(word): if word[0] in ["a","e","i","o","u"]: return "an" else: return "a"
 * 1) Generic grammar functions

def grammarPluralSuffix(word): if word[-1] == "y": return f"{word[:-1]}ies" elif word[-1] == "s": return f"{word}es" else: return f"{word}s"

possibleModes = [ "genericCheck", "indefArtic", "pluralSuffix", "slangMeans", ]

def grammar(mode,todo): if mode in possibleModes: pass else: return "unk"