Last active
August 29, 2015 14:05
-
-
Save moylop260/10f3e5c7e1c3acfa0ffb to your computer and use it in GitHub Desktop.
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
#moved to https://github.com/vauxoo-dev/gist-vauxoo/blob/master/check_print_and_pdb.py | |
''' | |
import ast | |
import sys | |
""" | |
This script check py file for no get "print" or "pdb" sentence. | |
""" | |
#file name of file py to check | |
fname = sys.argv[1] | |
with open(fname) as fin: | |
parsed = ast.parse(fin.read()) | |
for node in ast.walk(parsed): | |
if isinstance(node, ast.Print): | |
#if "print" sentence then add a out | |
print '"print" at line {} col {}'.format(node.lineno, node.col_offset) | |
elif isinstance(node, ast.Import): | |
for import_name in node.names: | |
if import_name.name == 'pdb': | |
#if "print" sentence then add a out | |
print '"import pdb" at line {} col {}'.format(node.lineno, node.col_offset) | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
maybe this should be written as a pylint plugin?