scription
light-weight library to enhance command-line scripts; includes conversion of
parameters to specified data types, parameter checking, basic input/output with
users, support for suid [1], sending email, executing sub-programs, and having
sub-commands within a script
decorators
- Script: sets global variables and/or parameters for Commands; the decorated
function will be called by Main/Run before any specified Command
- Command: marks function as a subcommand for the script (e.g. add, delete,
list, etc.); if no subcommand is specified on the command-line, scription
will look for a Command with the same name as the script
- Alias: registers other names for Commands (e.g. delete / remove / kill)
functions
- Main: if the importing module's __name__ is __main__, call Run() (this
allows for importing the script as a module)
- Run: unconditionally attempts to run the Script function (if any) and the
Command found on the command-line
Main() or Run() should be the last thing in the script
classes
- Spec: can be used when defining the command-line parameters (can also just
use tuples)
helper functions/classes
- abort: quits immediately by raising SystemExit
- Execute: class for executing other programs; uses subprocess.Popen by
default, but if `pty=True` is specified then `pty.fork` will be used
(handy for programs that only accept input from a pty)
- get_response: function for displaying text and getting feedback
- help: quits immediately, but adds a reference to --help in the quit message
- log_exception: logs an exception with logging.logger
- mail: rudimentary mail sender
- OrmFile: lightweight orm -- supports str, int, float, date, time,
datetime, bool, and path (which defaults to str); custom data types can
also be specified
- print: wrapper around print that adds a 'verbose_level' keyword (default: 1);
default verbosity is 0 (so print does nothing), but can be increased using
-v, -vv, --verbose, or --verbose=2 (in Python 2 the script must use
'from __future__ import print_function' to use scription's print)
- user_ids: context manager useful for suid scripts -- all actions taken
within the context are run as the user/group specified
features
- extra parameters defined by Script are global, and can be accessed from any
function or Command
- 'module' is a namespace inserted into the script
- 'script_command' is the Command selected from the command line (useful when
one needs to call the subcommand directly from a main() function)
- 'script_command_name' is the name of the script_command
- 'script_verbosity' is the level of verboseness selected (defaults to 0)
- 'script_name' is the name of the script
- builtin options are: --help, --verbose (-v or -vv), --version, --all-versions
--version attempts to display the version of the main package in use
--all-versions attempts to display the versions of any imported packages
- command-line is decoded to unicode under Python 2 (Python 3 does this for us)
[1] I use the suid-python program, available at http://selliott.org/python/suid-python.c
Raw data
{
"_id": null,
"home_page": "https://github.com/ethanfurman/scription.git",
"name": "scription",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Ethan Furman",
"author_email": "ethan@stoneleaf.us",
"download_url": "https://files.pythonhosted.org/packages/b6/c5/4b66b9c4a1fc0f72582992539e3c15b7fec4038f3570913d071b4eca9f47/scription-0.86.27.tar.gz",
"platform": null,
"description": "scription\n\nlight-weight library to enhance command-line scripts; includes conversion of\nparameters to specified data types, parameter checking, basic input/output with\nusers, support for suid [1], sending email, executing sub-programs, and having\nsub-commands within a script\n\n\ndecorators\n\n - Script: sets global variables and/or parameters for Commands; the decorated\n function will be called by Main/Run before any specified Command\n\n - Command: marks function as a subcommand for the script (e.g. add, delete,\n list, etc.); if no subcommand is specified on the command-line, scription\n will look for a Command with the same name as the script\n\n - Alias: registers other names for Commands (e.g. delete / remove / kill)\n\n\nfunctions\n\n - Main: if the importing module's __name__ is __main__, call Run() (this\n allows for importing the script as a module)\n\n - Run: unconditionally attempts to run the Script function (if any) and the\n Command found on the command-line\n\n Main() or Run() should be the last thing in the script\n\n\nclasses\n\n - Spec: can be used when defining the command-line parameters (can also just\n use tuples)\n\n\nhelper functions/classes\n\n - abort: quits immediately by raising SystemExit\n\n - Execute: class for executing other programs; uses subprocess.Popen by\n default, but if `pty=True` is specified then `pty.fork` will be used\n (handy for programs that only accept input from a pty)\n\n - get_response: function for displaying text and getting feedback\n\n - help: quits immediately, but adds a reference to --help in the quit message\n\n - log_exception: logs an exception with logging.logger\n\n - mail: rudimentary mail sender\n\n - OrmFile: lightweight orm -- supports str, int, float, date, time,\n datetime, bool, and path (which defaults to str); custom data types can\n also be specified\n\n - print: wrapper around print that adds a 'verbose_level' keyword (default: 1);\n default verbosity is 0 (so print does nothing), but can be increased using\n -v, -vv, --verbose, or --verbose=2 (in Python 2 the script must use\n 'from __future__ import print_function' to use scription's print)\n\n - user_ids: context manager useful for suid scripts -- all actions taken\n within the context are run as the user/group specified\n\n\nfeatures\n\n - extra parameters defined by Script are global, and can be accessed from any\n function or Command\n\n - 'module' is a namespace inserted into the script\n\n - 'script_command' is the Command selected from the command line (useful when\n one needs to call the subcommand directly from a main() function)\n\n - 'script_command_name' is the name of the script_command\n\n - 'script_verbosity' is the level of verboseness selected (defaults to 0)\n\n - 'script_name' is the name of the script\n\n - builtin options are: --help, --verbose (-v or -vv), --version, --all-versions\n --version attempts to display the version of the main package in use\n --all-versions attempts to display the versions of any imported packages\n\n - command-line is decoded to unicode under Python 2 (Python 3 does this for us)\n\n\n[1] I use the suid-python program, available at http://selliott.org/python/suid-python.c\n\n\n",
"bugtrack_url": null,
"license": "BSD License",
"summary": "simple script parameter parser",
"version": "0.86.27",
"project_urls": {
"Homepage": "https://github.com/ethanfurman/scription.git"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "fddc6ea8dafdba7348ec012fe125ef3fb85cc63005a19bf5331c02dbb0d2248d",
"md5": "09f27d16daa9ad608ab760cb5af4eaf1",
"sha256": "7a31b6bf5d61f797dc9c694d2e5e421de6a9d0c5aebc9b93de6404de3a8ab680"
},
"downloads": -1,
"filename": "scription-0.86.27-py2-none-any.whl",
"has_sig": false,
"md5_digest": "09f27d16daa9ad608ab760cb5af4eaf1",
"packagetype": "bdist_wheel",
"python_version": "py2",
"requires_python": null,
"size": 65536,
"upload_time": "2025-08-18T23:02:11",
"upload_time_iso_8601": "2025-08-18T23:02:11.344107Z",
"url": "https://files.pythonhosted.org/packages/fd/dc/6ea8dafdba7348ec012fe125ef3fb85cc63005a19bf5331c02dbb0d2248d/scription-0.86.27-py2-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1366e291e5e70114651b09c8bc3e7eb387daa96ce2cdc94b2e31158f688cd3dc",
"md5": "3e2574230b9b3e081c3c818c61bb9f95",
"sha256": "46852c313e027cb826a24cf6f8dfa7eb95488a255695dcffdbfffb87a9f999ab"
},
"downloads": -1,
"filename": "scription-0.86.27-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3e2574230b9b3e081c3c818c61bb9f95",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 65538,
"upload_time": "2025-08-18T23:02:13",
"upload_time_iso_8601": "2025-08-18T23:02:13.647752Z",
"url": "https://files.pythonhosted.org/packages/13/66/e291e5e70114651b09c8bc3e7eb387daa96ce2cdc94b2e31158f688cd3dc/scription-0.86.27-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b6c54b66b9c4a1fc0f72582992539e3c15b7fec4038f3570913d071b4eca9f47",
"md5": "7497b2667a38286e941f3acff6cc1119",
"sha256": "0722052e800ed1f7cbb5c3ebf3b4e7b020c663f5dac91fa544aebb9c6aa16477"
},
"downloads": -1,
"filename": "scription-0.86.27.tar.gz",
"has_sig": false,
"md5_digest": "7497b2667a38286e941f3acff6cc1119",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 65760,
"upload_time": "2025-08-18T23:02:15",
"upload_time_iso_8601": "2025-08-18T23:02:15.738496Z",
"url": "https://files.pythonhosted.org/packages/b6/c5/4b66b9c4a1fc0f72582992539e3c15b7fec4038f3570913d071b4eca9f47/scription-0.86.27.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-18 23:02:15",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ethanfurman",
"github_project": "scription",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "scription"
}