Package: ayo
ayoRun Python "create app" scripts from the web and GitHub repositories.Installation$ pip install --upgrade ayoInstall & Run A ScriptTo install and run script(s), you can use theayo icommand (which meansinstall).You can either run scripts from GitHub or run them locally from a specific directory.$ ayo i @username/repo @username/repo[branch] dir-nameCreating Your ScriptTo create your script, try:$ ayo newTwo files will be generated:ayo.config.jsonandayo-script.py. Currently,ayoitself provides two built-in utilities:Template: Used to create an app from a template folder or do it manuallySteps: Represents steps for your application, and caches previous data even when canceled.First, let's take a look atayo.config.json. This configuration JSON file determines which file(s)ayoneeds to run. Below is the default content that was generated using thenewcommand:{"bin":"ayo-script.py","with":[],"before-scripts":[]}bin: The file that runs the script. Think of it asmain.pywith: The files to also contain when downloading this from GitHub. Usually used when thebinfile requires modules. This field should only contain.pyfiles. Optional.before-scripts: Scripts to run before running thebinfile. Optional.Then, take a look atayo-script.py. You should see the default script:#!/usr/bin/pythonfromayoimportTemplate,true_or_falseyn=input("Can I install something for you?")ifnottrue_or_false(yn):exit(1)Template({"main.py":"# surprise! new app!"}).install()Decent code! But let's twist it a little bit: let's edit it so we can try out theStepsandTemplatefeature!It goes something like this:#!/usr/bin/pythonfromayoimportStepssteps=Steps()@steps.first# first stepdefhello_world():print("Hello, World!")@steps.then# then...defask_for_install(data):# 'data': data returned from the previous function# in this case, None!returninput("Can I install something for you?")@steps.thendefwrite_or_exit(data:str):# the 'data' is given from the 'input()'ifdata.lower()!="yes":exit(1)Template({"main.py":"# surprise! new app!","another-dir":{"README.md":"More content!"}}).install("new-app")steps.start()# start!WithSteps, whenever the user sneakly (or maybe they just want to go out for a bit) pressed^Cwhich causesKeyboardInterrupt, the program writes a new file (_ayo$cache.py) for cache-storing so that the next time they can quickly pick up from where they left off and continue their journey!Let's try out our freshly made script by running:$ ayo runAvailable CommandsTo check the available commands, run:$ ayo --helpReferenceTemplateRepresents an ayo script template.Args:contents (str| dict[str, Any]): The contents. Could be astrrepresenting the directory to use as a template or a directory dictionary.To usecontentsasstr, you'll need a directory called.ayo-templates. You can define templates here. See the below file tree example:.ayo-templates/
├─ template-a/
│  ├─ ... files & dirs
│
├─ template-b/
│  ├─ ... files & dirs
│
├─ .../To use the templates, simply use:fromayoimportTemplateTemplate("template-a").install("app-directory")Template("template-b").install("app-directory")In some occasions, you might want to ignore some files or directories from the template. To do so, pass in theignoresparameter:Template("template-a").install("app-directory",ignores={"unwanted-dir":...,# use '...' here".gitignore":...,"venv":{"bin":...}})As the name implies, "directory dictionaries" are just plain old Python dictionaries that work like file trees.ayosupports them!fromayoimportTemplateTemplate({"main.py":"# very normal main.py","venv":{"bin":{"README.md":"hahaha! this is the file content!"}}}).install("app-directory")Same as the above, you can ignore specific files and directories:Template({"main.py":"# very normal main.py",# ... existing code}).install("app-directory",{"main.py":...,# use '...' here".gitignore":...,"folders":{"work":{"too.txt":"WOW!"}}})StepsRepresents steps.Args:cache (bool, optional): Whether to cache (remember) data as completions or not, so that even ifKeyboardInterruptoccurs, the next time when this script executes, we can get the previous data, and skip directly to the last step the user is on.I personally don't like reading, but code is what I skip to.Here's an example of theStepsclass:fromayoimportStepssteps=Steps()@steps.first# first stepdefhello_world():print("Hello, World!")@steps.then# then...defask_for_install(data):# 'data': data returned from the previous function# in this case, None!returninput("Can I install something for you?")@steps.thendefwrite_or_exit(data:str):# the 'data' is given from the 'input()'ifdata.lower()!="yes":exit(1)Template({"main.py":"# surprise! new app!","another-dir":{"README.md":"More content!"}}).install("new-app")steps.start()# start!Now, whenever the user tries to^Cor exit the program,ayoremembers everything... NO CRIMES ALLOWED!If you're wondering how to remove the cache, simply run:$ ayo clean-cachetrue_or_false (tof)Checks whether the input provided by the user (Yn) is true or not.This is useful for "parsing" (more like understanding)Ynuser inputs.Args:_input (str): The input.false_if_unknown (bool, optional): Whether to returnFalseif received unrecognized input or not.fromayoimporttof# sneaky shortcuta="yes"print(tof(a))# -> Trueb="nope"print(tof(b))# -> Falsec="you'll never guess what i mean!!"print(tof(c))# -> Falseprint(tof(c,false_if_unknown=False))# ErrorBuilt by AWeirdScratcher (AWeirdDev). Right, I was bored.