Skip to content

Instantly share code, notes, and snippets.

@moylop260
Last active August 29, 2015 14:05
Show Gist options
  • Save moylop260/10f3e5c7e1c3acfa0ffb to your computer and use it in GitHub Desktop.
Save moylop260/10f3e5c7e1c3acfa0ffb to your computer and use it in GitHub Desktop.
#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)
'''
@gurneyalex
Copy link

maybe this should be written as a pylint plugin?

@moylop260
Copy link
Author

@gurneyalex,
Yes I will set a plugin cfg in pylint.cfg to test this cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment