blob: 5039548accc058bd470dbdb6ce4efc382046bd06 [file] [log] [blame]
Sapan Bhatia51111c12016-01-14 11:20:10 -05001Hi,
2
3I've written a tool called 'chuckmove' for helping move Python modules around in a source tree. You use it as follows. Lets say you want to relocate a module to a different location in the tree, and also rename it. So for instance, x is to become y.z. The syntax you use is:
4
5chuckmove -o x -n y.z <root directory>
6
7Invoking this command makes the tool recursively descend into the root directory, make a backup copy of each file (adding the prefix '.orig') and rewrite the imports in it, so that "import x" gets turned into "import y.z"
8
9It recognizes Python grammar, so it works with all of these forms:
10
11from x import a
12from x.b import c
13import x.d.e.f as foo # Comments are also handled
14
15...with the nit that lines with syntax/grammatical errors are left as is.
16
17For example, for the observer/synchronizer changes, I just had to do the following:
18
19chuckmove -o observer -n synchronizers.base xos
20
21...and then to generate a patch with the changes:
22
23gendiff xos .orig
24
25It's checked into the xos repository under tools (with a README file!).
26
27Sapan