Skip to content

Instantly share code, notes, and snippets.

@mbukatov
Last active November 25, 2016 11:59
Show Gist options
  • Save mbukatov/0e4cd76edd1f260ac372c5392b6a8f0b to your computer and use it in GitHub Desktop.
Save mbukatov/0e4cd76edd1f260ac372c5392b6a8f0b to your computer and use it in GitHub Desktop.

The script runs the change in place, but you can check what it will do via dry-run mode:

$ tree /home/martin/projects/webstr/webstr/common
/home/martin/projects/webstr/webstr/common
├── __init__.py
├── models
│   ├── actionpopups.py
│   ├── containers.py
│   ├── dialogs.py
│   ├── form.py
│   └── __init__.py
├── pages
│   ├── actionpopups.py
│   ├── containers.py
│   ├── dialogs.py
│   └── __init__.py
└── timeouts.py

2 directories, 11 files
$ ./raut2webstr-pagemodel-tree.py -d /home/martin/projects/webstr/webstr/common                                                                                                            
mkdir /home/martin/projects/webstr/webstr/common/actionpopups
touch /home/martin/projects/webstr/webstr/common/actionpopups/__ini__.py
mv /home/martin/projects/webstr/webstr/common/models/actionpopups.py /home/martin/projects/webstr/webstr/common/actionpopups/models.py
mkdir /home/martin/projects/webstr/webstr/common/containers
touch /home/martin/projects/webstr/webstr/common/containers/__ini__.py
mv /home/martin/projects/webstr/webstr/common/models/containers.py /home/martin/projects/webstr/webstr/common/containers/models.py
mkdir /home/martin/projects/webstr/webstr/common/form
touch /home/martin/projects/webstr/webstr/common/form/__ini__.py
mv /home/martin/projects/webstr/webstr/common/models/form.py /home/martin/projects/webstr/webstr/common/form/models.py
mkdir /home/martin/projects/webstr/webstr/common/dialogs
touch /home/martin/projects/webstr/webstr/common/dialogs/__ini__.py
mv /home/martin/projects/webstr/webstr/common/models/dialogs.py /home/martin/projects/webstr/webstr/common/dialogs/models.py
mkdir /home/martin/projects/webstr/webstr/common/actionpopups
touch /home/martin/projects/webstr/webstr/common/actionpopups/__ini__.py
mv /home/martin/projects/webstr/webstr/common/pages/actionpopups.py /home/martin/projects/webstr/webstr/common/actionpopups/pages.py
mkdir /home/martin/projects/webstr/webstr/common/containers
touch /home/martin/projects/webstr/webstr/common/containers/__ini__.py
mv /home/martin/projects/webstr/webstr/common/pages/containers.py /home/martin/projects/webstr/webstr/common/containers/pages.py
mkdir /home/martin/projects/webstr/webstr/common/dialogs
touch /home/martin/projects/webstr/webstr/common/dialogs/__ini__.py
mv /home/martin/projects/webstr/webstr/common/pages/dialogs.py /home/martin/projects/webstr/webstr/common/dialogs/pages.py
rm /home/martin/projects/webstr/webstr/common/models/__init__.py
rm /home/martin/projects/webstr/webstr/common/pages/__init__.py
rmdir /home/martin/projects/webstr/webstr/common/models
rmdir /home/martin/projects/webstr/webstr/common/pages

Then when you run in for real:

$ ./raut2webstr-pagemodel-tree.py /home/martin/projects/webstr/webstr/common
$ tree /home/martin/projects/webstr/webstr/common
/home/martin/projects/webstr/webstr/common
├── actionpopups
│   ├── __ini__.py
│   ├── models.py
│   └── pages.py
├── containers
│   ├── __ini__.py
│   ├── models.py
│   └── pages.py
├── dialogs
│   ├── __ini__.py
│   ├── models.py
│   └── pages.py
├── form
│   ├── __ini__.py
│   └── models.py
├── __init__.py
└── timeouts.py

4 directories, 13 files

Another way to see what changed is via git:

$ git st
## mbukatov_changes
R  pages/__init__.py -> actionpopups/__ini__.py
R  models/actionpopups.py -> actionpopups/models.py
R  pages/actionpopups.py -> actionpopups/pages.py
R  models/__init__.py -> containers/__ini__.py
R  models/containers.py -> containers/models.py
R  pages/containers.py -> containers/pages.py
A  dialogs/__ini__.py
R  models/dialogs.py -> dialogs/models.py
R  pages/dialogs.py -> dialogs/pages.py
A  form/__ini__.py
R  models/form.py -> form/models.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment