Package: pypals
pypalsTurn python snippets into command line buddies!Keeps your python scripts and snippets as command line pals.installationGet the package from pypi i.e.$ python3 -m pip install pypals --upgradesee screen shot in archive folder for using pypal in vscode terminalusageSometimes you write code maybe to do some random job or snippet, scrape something, send a tweet, whatever.It's useful to keep those bits of odd code somewhere. pypals are easy to remember ages later.$ python3 -m pypals sportsfan
$ sportsfan doesn't exist, create them now? yes or no
$ > yes
$ your name?
$ > mike
$ Hi my name is sportsfan, Thankyou for creating me!
$ I am listening...sportsfan has been created for you in a /pypals directory. He can gather data about sports using any python commands you write and put in that foldernow try running this command...$ hellonow look in pypals/sportsfan/hello/hello.py file to see an example of a command.To create commands try typing 'do something' at the prompt.You will see it creates it for you. You can now just edit the file created and fill it in with your code.Next try typing 'quit'If you're editing a command you don't need to restart pypal. It will reload the command. You can even type 'r' to rerun it at the prompt.parameterspass any words after your command it will pick them up as parameters.when creating a command it will ask you what to type as a response, you can put any string.
however if you try instead typing:{args}Now run your command and type some extra words after it. cool huh.TODO - explain commands between bots / sharing commands
you can import pypals into other pypals and share commands between them.loggingtodo - explain logging. now off by default.You can also call or execute any commands you created directly from the command line. i.e.python3 -m pypals sportsfan hellometa / varsAt the root of every pypal you create is a _meta file to store variables.If you don't like json you can change the config type (see below)You can access any variables stored in _meta from your commands by using the passed in 'o' which is a reference to self.print(f"Hello, to you { o.o['friend']}!")You can store more variables in there if required just add them manually.shortcutsWhile a given pypal is running you can pass it the following single letter commands as shortcuts:r - re-run previous command. (i.e. after editing the python file)h - historyq - quitc - list all the variables in the config filec=json - change the config file to be jsonc=ini - change the config file to be inic=xml - change the config file to be xmlc=txt - change the config file to be txtd - generate a docs file inside the given pypals folder that list out all the commands you have created. (once you create a docs file for a pypal, it will auto update every time you create a new command. so don't edit it manually or you will lose your changes.)CLIpypals has recently been updated to have a cli help system.the following command might be useful...for a list of all commands$ python3 -m pypals -hthe version of pypals you are using$ python3 -m pypals -vshow a list of all your pypals$ python3 -m pypals -lgenerate a top level docs file that lists out all your pypals in the root of the pypals folder.$ python3 -m pypals -dAPIEvery command gets passed a reference to self 'o' which is a reference to the pypals object.There are some commands you can use on this object. But mostly you can use pypal to create your ownTODO - explain APIdocumentationnote : you can't use package names for commands. i.e. builtins, testnote : use task manager to montior botsthe base path to a command is available if loading writing files to same folder:o.context.COMMAND_PATHpypals uses includes rich and domonic libraries so your commands should be able to import and use them.morecron notesput in sometask.sh file chmod +x the file.echo "do some job batch 1" | nohup python3 -m pypals jobs >/dev/null 2>&1 &you may want those to self terminate *see 'quit'makefile notessomething like this in your makefile to boot one or more fasterpypal:
	cd /home/ubuntu/Desktop/someapp/automate/; \
	python3 -m pypals myscraper somefuncIf you run several pypals simoultaneously you can trash them all easy by putting this in your makefile:killall:
	pkill -9 pythonNoteshttps://medium.com/@joel.barmettler/how-to-upload-your-python-package-to-pypi-65edc5fe9c56aboutpypals was my first python project written in python2 in about 2012. It is a useful way to organise code snippets and do research. In 2019 I ported it to python 3 while learning to make pip packages.please use it responsibly and if you want to contribute, fork it and send me a pull request.