Package: playgroundtools
playgroundtoolsAn interface for managing playground projects.OverviewThis package is intended to provide a quick and easy way to set up Python "projects," each containing their own files, folders, virtual environment, and installed packages. This also includes the ability to run these projects (calledplaygrounds) and delete them. This can be done either through the CLI or through the interactive GUI (with limited capabilities). The exact configuration for the creation and execution of these playgrounds are foundhere, in the package's configuration file.For example, creating anapiplayground results in the following file structure:playground
│   .env
│   main.py
│   reset.py
│   settings.json
│
├───.venv
│       ...
│
├───api
│       config.py
│       crud.py
│       database.py
│       deps.py
│       models.py
│       schemas.py
│       __init__.py
│
└───requirements
        requirements.inCommandsnew:
Creates a playground.$playgroundnew[-h][-iLIB[LIB...]][-v]-nNAME[-oOPTIONS]typeFor example, to create anapiproject:# We can specify a list of optional packages to install via pip by using the `-i` option$playgroundnewapi-nmy_api-irequests-v# verbosity can be set with the -v optionA customized creation can be accomplished through use of the-ooption. SeeConfiguration Formattingfor more detail.# `package` is a custom playground type$playgroundnewpackage-nmy_package-o"{\"author\": \"John Doe\"}"# customization can be done via the `-o` optionrun:
Runs a playground.$playgroundrun[-h][-mMODULE][-aARGS[ARGS...]]nameFor example:$playgroundrunconsole_appdelete:
Deletes a playground.$playgrounddelete[-h]nameFor example:$playgrounddeletejupyter_testsconfig:
Reads or modifies the configuration. See theUsing the CLIsection for more detail.$playgroundconfig[-h][-kREAD]{delete,set}For example:$playgroundconfigset-kapi.folders-v"[\"api\", \"api/routers\"]"Graphical User InterfaceInvokingplayground-guiwill open the interactive GUI, allowing for the creation and deletion of playgrounds.Playground SettingsSettings for a playground can be configured via itssettings.jsonfile.
The available options are:python: a path that points to the Python installation used to run the playground.module: the module to run (by invocation of-m {module})args: the arguments to pass to the module (-m {module} {args ...})ConfigurationTo configure the installation ofplaygroundtools, utilize theconfigcommand in the CLI or manually edit theconfig.jsonfile.The available options are:folders: a list of folders that should be placed inside the playground upon creation.files: maps file names to lists containing the contents of the file by line.lib: the packages to be installed upon creation of the playground.module: the module to run when the playground is executed via-m {module}.args: the arguments to pass to the module upon execution (-m {module} {args ...}).(OPTIONAL)format: specifies strings that are used for interpolation (see below)FormattingKeys and values can be interpolated using one of the strings below in the format${string}in theconfig.jsonfile.name: the playground name.Format strings can be customized to include common conventions. For instance, one can include anauthorkey in theformatsection of their playground type to specify a default author when creating a package and reference it in the setup file of the playground by using${author}. An example of the usage of these format strings is shown below, in theUsing JSONsection.Format strings also allow flexibility in the creation of playgrounds. You can override the default values for these strings when invoking thenewcommand in the CLI by specifying the-ooption, followed by JSON which determines the value for these fields upon creation.Using the CLIconfig delete:
Deletes a key from the configuration.$playgroundconfigdelete[-h][-kKEY][-fFILE]For example:$playgroundconfigdelete"package"Keys from a custom config file can also be deleted:$playgroundconfigdelete-fuser_config.jsonconfig set:
Sets a key in the configuration.$playgroundconfigset[-h][-kKEY][-vVALUE][-fFILE]For example:$playgroundconfigset-k"api.folders"-v"[\"api\", \"api/routers\", \"api/db\"]"Configuration can also be added from a custom JSON file:$playgroundconfigset-fuser_config.jsonUsing JSONTheconfig.jsonfile simply contains configurations for different types of playgrounds. The settings for each type are specified by the available options aforementioned.For example, to create apackagetype, one could use:{
    // ...
    "package": {
        "folders": [
            "${name}",
            "tests"
        ],
        "files": {
            "setup.cfg": [
                // File contents go here...
            ],
            "pyproject.toml": [
                // File contents go here...
            ],
            "setup.py": [
                // File contents go here...
            ]
            // ...
        },
        "lib": [
            "${name}",
            "${formatter}",
            "${linter}",
            "${build}",
            "${upload}",
            "isort"
        ],
        "module": "${name}",
        "args": [],
        "format": {
            "formatter": "black",
            "build": "build",
            "upload": "twine",
            "linter": "flake8"
        }
    }
}