forked from MostAwesomeDude/construct
-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unsix script added until the issue is resolved.
- Loading branch information
1 parent
6f9caf2
commit c0644ae
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/python3 | ||
|
||
import re, os, sys | ||
|
||
def processfolder(top): | ||
for root, dirs, files in os.walk(top): | ||
for f in files: | ||
if f.endswith('.py'): | ||
processfile(os.path.join(root, f)) | ||
for d in dirs: | ||
processfolder(os.path.join(root, d)) | ||
|
||
def processfile(fname): | ||
print(fname+'... ', end='') | ||
with open(fname, 'rt') as f: | ||
txt = f.read() | ||
txt = re.sub('import six\n', '', txt) | ||
txt = re.sub(r'six\.(b\("[^"]*"\))', | ||
lambda s: 'b'+s.expand(r'\1').strip('b()'), txt) | ||
txt = re.sub(r'six\.(u\("[^"]*"\))', | ||
lambda s: 'u'+s.expand(r'\1').strip('u()'), txt) | ||
with open(fname, 'wt') as f: | ||
f.write(txt) | ||
print('done') | ||
|
||
|
||
processfolder(sys.argv[1]) |