Common tools we use as PyBites
Project description
build
Can be added to correct path after
PyBites Tools
Welcome to PyBites Tools repo!
This is a collection repo for all things python that we have found helpful to get your modern Python project up and going.
Get started
Using this repo in your project
pip install pybites-tools
To use the command-line scripts (some scripts you need to set environment variables), for example:
(venv) $ zen
The Zen of Python has been copied to your clipboard
(venv) $ s3
usage: s3 [-h] -f FILE [-b BUCKET] [-a ACL]
s3: error: the following arguments are required: -f/--file
(venv) $ email
usage: email [-h] -s SUBJECT -m MESSAGE [-e EMAIL]
email: error: the following arguments are required: -s/--subject, -m/--message
Or use tools by importing them in your scripts, for example:
>>> from pybites_tools.license import generate_license_key
>>> generate_license_key()
'35HN2KIW-K3ON4F94-IGJ1UN32-EAXSRZLF'
Developer setup
If you want to contribute or modify the repo, make a fork and clone it, for example:
git clone git@github.com:bbelderbos/pybites-tools.git
cd pybites-tools
To get started run:
make setup
This will create a virtual environment and install the dependencies.
Before committing any code, you should install and run pre-commit. Why pre-commit?
Just run pre-commit install
.
For some tools, you will need environment variables. You can set them by copying over the .env-template
file to .env
.
Useful tools
Send email
Configure the EMAIL_*
environment variables; then you can run it like this:
$ python -m pybites_tools.sendemail -s "test subject" -m "test message" --email recipient@example.com
If you set EMAIL_DEFAULT_TO_EMAIL
, you can leave off the --email
switch. This is useful if you want to send yourself a reminder often.
For example, you could add something like this in your .zshrc
:
function remind {
(cd $HOME/code/pybites-tools && source venv/bin/activate && python -m pybites_tools.sendemail -s "$1" -m "$2")
}
Then you can send yourself a quick email like this:
$ remind "blog post" "git stats"
Uploading files to an S3 bucket
For this, you need to set the AWS_*
configuration variables in .env
.
Then you can upload a file using:
$ python -m pybites_tools.aws -f file-path (-b bucket) (-a acl)
WorldClock from the command line
Add the timezones that you would like displayed to the TIMEZONE_LIST configuration variable in .env
. (List of all timezones here). And uncomment/set the TIME_FORMAT in case you want a different output format (see strftime() and strptime() Format Codes for options).
When working with others in multiple timezones you usually refer to your local timezone for reference. That said you can uncomment/set the TIMEZONE to your local one to avoid using the -tz
command line parameter every time (if omitted UTC is used).
Like this:
TIMEZONE_LIST=["America/Los_Angeles","CET","Australia/Sydney"]
TIME_FORMAT="%H:%M %z" # 24-hour clock with UTC offset
TIMEZONE="Europe/Berlin"
Then:
$ python -m pybites_tools.worldclock
America/Los_Angeles 08:35PM
CET 05:35AM
Australia/Sydney 02:35PM
Or specify a time in some other timezone to be converted (e.g. to convert 10:55PM in London):
$ python -m pybites_tools.worldclock -hr 22 -min 55 -tz Europe/London
America/Los_Angeles 02:55PM
CET 11:55PM
Australia/Sydney 08:55AM
Around the dates where daylight saving times (DST) are changed finding the right timeslot for a meeting/call in the next week can be off due to the DST changed. That's why you can use the --year
, --month
and --day
to find the correct time.
$ python -m pybites_tools.worldclock -hr 15 -min 0 -y 2022 -m 3 -d 10
America/Los_Angeles 07:00AM
CET 04:00PM
Australia/Sydney 02:00AM
$ python -m pybites_tools.worldclock -hr 15 -min 0 -y 2022 -m 3 -d 15
America/Los_Angeles 08:00AM
CET 04:00PM
Australia/Sydney 02:00AM
Copy Zen of Python to clipboard
Why not send it to a coder friend from time to time?
$ python -m pybites_tools.zen
The Zen of Python has been copied to your clipboard
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 pybites-tools-0.2.tar.gz
.
File metadata
- Download URL: pybites-tools-0.2.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23ac8dfb847acc7b2e213d25cf72126e4d6e8263e49dc5dbc49cb620e99d7118 |
|
MD5 | 694b21f371ea9056270c9b56938ee8b1 |
|
BLAKE2b-256 | 3467dd808781f3e1313e231050d6f2e931b803bcab944c68690a74f7a2f41ecd |
File details
Details for the file pybites_tools-0.2-py3-none-any.whl
.
File metadata
- Download URL: pybites_tools-0.2-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b69d1686ad122b2f727152ea207a182f3033bc54a00675a58fb27aa8f66c944 |
|
MD5 | 9cbdb857a69e04e9144e259891f8a71e |
|
BLAKE2b-256 | 1720a1838847af92aaf5a7bd54d7d66429834e00fc638d2588a3b5f40ac523cd |