https://github.com/evrone/mega-copy
Automated refactoring for Python (and not only) files
https://github.com/evrone/mega-copy
Last synced: 4 months ago
JSON representation
Automated refactoring for Python (and not only) files
- Host: GitHub
- URL: https://github.com/evrone/mega-copy
- Owner: evrone
- License: mit
- Created: 2022-07-06T20:25:07.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-06-09T12:03:51.000Z (about 3 years ago)
- Last Synced: 2026-01-13T16:22:13.649Z (5 months ago)
- Language: Python
- Homepage:
- Size: 34.2 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mega-copy
This is a tool that helps to edit/refactor code in bulk. Useful when developing few similar features in your system
It works with:
1. Python files in "special" (Python-language specific) mode
2. "Other" files in "simple" (format-agnostic) mode
# Installation & Usage
1. Clone this repo:
```
git clone https://github.com/andrewboltachev/mega-copy.git
```
2. Create virtual environment:
```
mkvirtualenv mega-copy # (or use venv)
pip install -r requirements.txt
```
and a helper script to run the tool (e.g. `~/bin/mega-copy.sh`):
```bash
/home/andrey/.virtualenvs/mega-copy/bin/python /home/myuser/mega-copy/mega-copy.py $@
```
2. Suppose you want to refactor your Python code, replacing something called "property sale" to something else named "sales order". Run:
```
> mega.copy.sh pyshow property-sale sales-order
```
The tool will generate the following "replace map" (taking into account all possible spellings):
```python
{
"propertysale": "salesorder",
"property sale": "sales order",
"property-sale": "sales-order",
"property_sale": "sales_order",
"PROPERTYSALE": "SALESORDER",
"PROPERTY SALE": "SALES ORDER",
"PROPERTY-SALE": "SALES-ORDER",
"PROPERTY_SALE": "SALES_ORDER",
"PropertySale": "SalesOrder",
"Property Sale": "Sales Order",
"Property-Sale": "Sales-Order",
"Property_Sale": "Sales_Order",
"Propertysale": "Salesorder",
"Property sale": "Sales order",
"Property-sale": "Sales-order",
"Property_sale": "Sales_order",
"propertySale": "salesOrder",
"property Sale": "sales Order",
"property-Sale": "sales-Order",
"property_Sale": "sales_Order"
}
```
and below **show** all **Python** code expressions affected by it in code (your current directory)
Instead of `pyshow` you can then use another command — `pyren`, to rename all occurencies in the code in-place
## License
This project is licensed under the [MIT License](LICENSE).
## Sponsors
Visit [Evrone](https://evrone.com/) website to get more information about the [projects](https://evrone.com/cases) build.