Change all instances of `self` to `this` in one randomly chosen scope
Project description
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]
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 randomly_change_self-0.2.0.tar.gz
.
File metadata
- Download URL: randomly_change_self-0.2.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 173b3ec0154479403ec8aeaa21075d5386b76137a44cbed60fd8988e77a10255 |
|
MD5 | 22652dcd5ca0fb8237aa81cc45162e0b |
|
BLAKE2b-256 | 84f6079eaf97a0d8203c12bd0acbd60b1c3726feeeae9a4684a35441d4b92f47 |
File details
Details for the file randomly_change_self-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: randomly_change_self-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | faca1512fcd5ef49868cb81c49c36758e9c94d30c76ad15e75fd99d888f4d44a |
|
MD5 | 1ea4a54070d5a3463ec850fbb5e2860e |
|
BLAKE2b-256 | db456e3da3bc31266d4e5bb13f4f904087431aa872f1ccbe05d4ee05ef9a6b71 |