Created
November 10, 2013 05:59
-
-
Save cpatulea/7394412 to your computer and use it in GitHub Desktop.
Find Python string literals that should probably be Unicode
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
#!/usr/bin/python | |
import ast, _ast, os | |
for root, dirs, files in os.walk('.'): | |
for name in files: | |
if name.endswith('.py'): | |
full = os.path.join(root, name) | |
t = ast.parse(open(full).read()) | |
for n in ast.walk(t): | |
if isinstance(n, _ast.Str) and not isinstance(n.s, unicode): | |
if any(ord(c) > 127 for c in n.s.decode('utf-8')): | |
print full, 'line', n.lineno, 'col', n.col_offset, ':', n.s.decode('utf-8') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could have marked it as Python source, so we could get syntax highlighting :)