randomly-change-self
Change all instances of self to this in one randomly chosen scope per file.
Inspired by David Beazley's toot.
Installation
Install from PyPi with your favorite pip invocation:
$ python3 -m pip install randomly-change-self
You can confirm proper installation via the randomly-change-self CLI:
$ randomly-change-self --help
usage: randomly-change-self [-h] [--replace-with REPLACE_WITH]
[--consider-mercury-in-retrograde CONSIDER_MERCURY_IN_RETROGRADE]
[filenames ...]
positional arguments:
filenames
options:
-h, --help show this help message and exit
--replace-with REPLACE_WITH
--consider-mercury-in-retrograde CONSIDER_MERCURY_IN_RETROGRADE
Arguments
filenames
A collection of filename(s) to process. While this isn't required, you should probably pass some filename(s) if you want something to happen.
replace-with
Specify the string to replace "self" with. Defaults to "this"
It's assumed that this value is a valid Python identifier. No validation of this is done, we're all adults here.
consider-mercury-in-retrograde
Set to True if you only want to make changes if Mercury is in retrograde.
NOTE: Because it turns out that astrophysics is a little challenging and I haven't done it since college, this is currently implemented as an API call to the Mercury Retrograde API. This call should fail gracefully, and if an issue is encountered then your flag will be ignored and your code will get changed anyway.
Pre-Commit
You can even use this as a pre-commit hook. Wow!
- repo: https://github.com/sco1/randomly-change-self
rev: v0.2.0
hooks:
- id: randomly-change-self
args: [--consider-mercury-in-retrograde=False]
Metadata
Release files for randomly-change-self 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| randomly_change_self-0.2.0.tar.gz | 4.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| randomly_change_self-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.4 kB
Release files / randomly_change_self-0.2.0.tar.gz
| Download URL | randomly_change_self-0.2.0.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
173b3ec0154479403ec8aeaa21075d5386b76137a44cbed60fd8988e77a10255
|
|
BLAKE2b-256 checksum How to use checksums |
84f6079eaf97a0d8203c12bd0acbd60b1c3726feeeae9a4684a35441d4b92f47
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.18
|
Release files / randomly_change_self-0.2.0-py3-none-any.whl
| Download URL | randomly_change_self-0.2.0-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
faca1512fcd5ef49868cb81c49c36758e9c94d30c76ad15e75fd99d888f4d44a
|
|
BLAKE2b-256 checksum How to use checksums |
db456e3da3bc31266d4e5bb13f4f904087431aa872f1ccbe05d4ee05ef9a6b71
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.18
|