ctbl_tools: miscelaneous daily tasks helpers
A package with miscelaneous classes meant to help at coding console helpers. Currently there are three classes:
- config: it implements a config file that saves itself. It is a specialization of configparser.
- process: it runs external processes, it saves the return code, and it helps (a little bit) to parse the standard output (or the standard error).
- git: a simple interface for git commands.
config: a self-preserving config file
It implements a config file that saves itself.
The idea is: we want to use a config file for an application, which is a simple text file that contains pairs of values, in a similar fashion to an INI file. If the file exists, it is used; if it doesn't, it is created. We use configparser for this.
An example:
from ctbl_tools.config import config
cfg = config(initpath = '~/somewhere/blabla.ini')
cfg.create_section('my_configuration')
cfg.set('my_configuration', 'x', 1)
cfg.set('my_configuration', 'y', '2')
When the program above ends, it will save all created configuration to the file ~/somewhere/blabla.ini.
process: a helper to run external programs
It runs an external program, and it stores the return code and both the standard output and standard error.
You first create an object of this type:
p = process()
Then run a command:
p.run("whoami")
Immediately after you gain access to the return code, stdout and stderr:
print(p.returncode)
for line in p.stdout:
print(line)
You may check if return code was 0 (i.e., all good) by checking p.is_ok() to be true. You may also check whether there is any stdout or any stderr with p.is_there_stdout() and with p.is_there_stderr(), respectively.
Finally you may extract information out of stdout by using extract(). This method receives a regular expression and a boolean that is true by default (meaning that you want to inspect stdout; if false it will inspect stderr instead). The method will look for all matches in each line of stdout and store them in a list. The list stores as many elements as lines stdout has, and each element is a list of all matches within the corresponding line.
git: a simple git interface
It provides a simple programmatical interface to git.
First, you create a git object by providing a local path to a repo:
from ctbl_tools.git import git
x = git("~/Dev/my_repo")
The previous will fail if provided path is not a git repo.
Then you may either get the remote urls with x.get_remote(), or a get the status of the working tree by invoking x.get_status().
You may also do a commit with a list of files with x.commit(list-of-files), or do a push (x.git_push('my-commit-message')) or a pull (x.git_pull()).
This package also includes two auxiliary functions:
git_clone(url:str, path:str): It clonesurlintopath.is_git_url(url:str): It checks whetherurlis a valid git url.
Metadata
Release files for ctbl-tools 0.1.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ctbl_tools-0.1.9.tar.gz | 8.8 kB | Without provenance | Details for ctbl_tools-0.1.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ctbl_tools-0.1.9-py3-none-any.whl | Python 3 | none | any | Details for ctbl_tools-0.1.9-py3-none-any.whl |
Total release size: 18.5 kB
Release files / ctbl_tools-0.1.9.tar.gz
| Download URL | ctbl_tools-0.1.9.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dece00a9df90cbf923eb00b0f051f9677811ddc01394fab4cc1a11b64a4abc8b
|
|
BLAKE2b-256 checksum How to use checksums |
1d74e0d6cef0b9e5275bb8399d4c2b1b4ee05431144adc154e48ab3faa00700e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / ctbl_tools-0.1.9-py3-none-any.whl
| Download URL | ctbl_tools-0.1.9-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
101ded15f58114a6f17e8223cd9ee7d174b088659eec1115a149d9bba99fc09b
|
|
BLAKE2b-256 checksum How to use checksums |
eab5a5595cac1097cd42764dc26e75a47ba7bf613107c7468cdf33cfbb75e9a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for ctbl-tools 0.1.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.