Skip to content

Commit

Permalink
Unsix script added until the issue is resolved.
Browse files Browse the repository at this point in the history
  • Loading branch information
arekbulski committed Aug 25, 2016
1 parent 6f9caf2 commit c0644ae
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions unsix.py
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])

0 comments on commit c0644ae

Please sign in to comment.