An interface for managing playground projects.
Project description
playgroundtools
An interface for managing playground projects.
Overview
This 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 (called playgrounds) 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 found here, in the package's configuration file.
For example, creating an api
playground 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.in
Commands
new
:
Creates a playground.
$ playground new [-h] [-i LIB [LIB ...]] [-v] -n NAME [-o OPTIONS] type
For example, to create an api
project:
# We can specify a list of optional packages to install via pip by using the `-i` option
$ playground new api -n my_api -i requests -v # verbosity can be set with the -v option
A customized creation can be accomplished through use of the -o
option. See Configuration Formatting for more detail.
# `package` is a custom playground type
$ playground new package -n my_package -o "{\"author\": \"John Doe\"}" # customization can be done via the `-o` option
run
:
Runs a playground.
$ playground run [-h] [-m MODULE] [-a ARGS [ARGS ...]] name
For example:
$ playground run console_app
delete
:
Deletes a playground.
$ playground delete [-h] name
For example:
$ playground delete jupyter_tests
config
:
Reads or modifies the configuration. See the Using the CLI section for more detail.
$ playground config [-h] [-k READ] {delete,set}
For example:
$ playground config set -k api.folders -v "[\"api\", \"api/routers\"]"
Graphical User Interface
Invoking playground-gui
will open the interactive GUI, allowing for the creation and deletion of playgrounds.
Playground Settings
Settings for a playground can be configured via its settings.json
file.
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 ...}
)
Configuration
To configure the installation of playgroundtools
, utilize the config
command in the CLI or manually edit the config.json file.
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)
Formatting
Keys and values can be interpolated using one of the strings below in the format ${string}
in the config.json file.
name
: the playground name.
Format strings can be customized to include common conventions. For instance, one can include an author
key in the format
section 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 the Using JSON section.
Format strings also allow flexibility in the creation of playgrounds. You can override the default values for these strings when invoking the new
command in the CLI by specifying the -o
option, followed by JSON which determines the value for these fields upon creation.
Using the CLI
config delete
:
Deletes a key from the configuration.
$ playground config delete [-h] [-k KEY] [-f FILE]
For example:
$ playground config delete "package"
Keys from a custom config file can also be deleted:
$ playground config delete -f user_config.json
config set
:
Sets a key in the configuration.
$ playground config set [-h] [-k KEY] [-v VALUE] [-f FILE]
For example:
$ playground config set -k "api.folders" -v "[\"api\", \"api/routers\", \"api/db\"]"
Configuration can also be added from a custom JSON file:
$ playground config set -f user_config.json
Using JSON
The config.json file simply contains configurations for different types of playgrounds. The settings for each type are specified by the available options aforementioned.
For example, to create a package
type, 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"
}
}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file playgroundtools-1.10.1.tar.gz
.
File metadata
- Download URL: playgroundtools-1.10.1.tar.gz
- Upload date:
- Size: 22.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e546488c9e44d2f598c0c58e78ed25d60407da7d645c759628f0dc3f13471ba5 |
|
MD5 | 948756e5a3b63cdbac7330ae4558a627 |
|
BLAKE2b-256 | ab9948ca9287f16589bffe0d878d058026bd9b2352a0f02eb78707bdabbad2e8 |
File details
Details for the file playgroundtools-1.10.1-py3-none-any.whl
.
File metadata
- Download URL: playgroundtools-1.10.1-py3-none-any.whl
- Upload date:
- Size: 25.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b461f66ffa05355b79f29724a1d3134e668d10c24c23c6d1710d71233754bb24 |
|
MD5 | f6605b7b91d33082aa56bc4407b46ef2 |
|
BLAKE2b-256 | 37927de1faeba8e6cb49903aa7d8e74e46b17eb3656860d1edf4f0b080bc899f |