MCPcopy Index your code
hub / github.com/RustPython/RustPython / check

Function check

Lib/tabnanny.py:70–133  ·  view source on GitHub ↗

check(file_or_dir) If file_or_dir is a directory and not a symbolic link, then recursively descend the directory tree named by file_or_dir, checking all .py files along the way. If file_or_dir is an ordinary Python source file, it is checked for whitespace related problems. The diag

(file)

Source from the content-addressed store, hash-verified

68 return self.line
69
70def check(file):
71 """check(file_or_dir)
72
73 If file_or_dir is a directory and not a symbolic link, then recursively
74 descend the directory tree named by file_or_dir, checking all .py files
75 along the way. If file_or_dir is an ordinary Python source file, it is
76 checked for whitespace related problems. The diagnostic messages are
77 written to standard output using the print statement.
78 """
79
80 if os.path.isdir(file) and not os.path.islink(file):
81 if verbose:
82 print("%r: listing directory" % (file,))
83 names = os.listdir(file)
84 for name in names:
85 fullname = os.path.join(file, name)
86 if (os.path.isdir(fullname) and
87 not os.path.islink(fullname) or
88 os.path.normcase(name[-3:]) == ".py"):
89 check(fullname)
90 return
91
92 try:
93 f = tokenize.open(file)
94 except OSError as msg:
95 errprint("%r: I/O Error: %s" % (file, msg))
96 return
97
98 if verbose > 1:
99 print("checking %r ..." % file)
100
101 try:
102 process_tokens(tokenize.generate_tokens(f.readline))
103
104 except tokenize.TokenError as msg:
105 errprint("%r: Token Error: %s" % (file, msg))
106 return
107
108 except IndentationError as msg:
109 errprint("%r: Indentation Error: %s" % (file, msg))
110 return
111
112 except SyntaxError as msg:
113 errprint("%r: Syntax Error: %s" % (file, msg))
114 return
115
116 except NannyNag as nag:
117 badline = nag.get_lineno()
118 line = nag.get_line()
119 if verbose:
120 print("%r: *** Line %d: trouble in tab city! ***" % (file, badline))
121 print("offending line: %r" % (line,))
122 print(nag.get_msg())
123 else:
124 if ' ' in file: file = '"' + file + '"'
125 if filename_only: print(file)
126 else: print(file, badline, repr(line))
127 return

Callers 12

mainFunction · 0.70
__runMethod · 0.70
get_awaitable_iterFunction · 0.50
slot_initMethod · 0.50
recursive_issubclassMethod · 0.50
try_from_objectMethod · 0.50
nextFunction · 0.50
py_newMethod · 0.50
try_into_typedMethod · 0.50
get_awaitable_iterMethod · 0.50
as_numberMethod · 0.50
frozen_origname_matchesFunction · 0.50

Calls 14

errprintFunction · 0.85
process_tokensFunction · 0.85
reprFunction · 0.85
islinkMethod · 0.80
listdirMethod · 0.80
normcaseMethod · 0.80
get_lineMethod · 0.80
get_msgMethod · 0.80
printFunction · 0.50
isdirMethod · 0.45
joinMethod · 0.45
openMethod · 0.45

Tested by 2

__runMethod · 0.56
frozen_origname_matchesFunction · 0.40