This is a tool that helps to edit/refactor code in bulk. Useful when developing few similar features in your system
It works with:
- Python files in "special" (Python-language specific) mode
- "Other" files in "simple" (format-agnostic) mode
- Clone this repo:
git clone https://github.com/andrewboltachev/mega-copy.git
- 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
):
/home/andrey/.virtualenvs/mega-copy/bin/python /home/myuser/mega-copy/mega-copy.py $@
- 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):
{
"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
This project is licensed under the MIT License.
Visit Evrone website to get more information about the projects build.
![Sponsored by Evrone](https://user-images.githubusercontent.com/417688/34437029-dbfe4ee6-ecab-11e7-9d80-2b274b4149b3.png)