MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / check

Function check

tools/python-3.11.9-amd64/Lib/tabnanny.py:73–132  ·  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

(file)

Source from the content-addressed store, hash-verified

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

Callers 3

mainFunction · 0.70
__runMethod · 0.70
checkMethod · 0.50

Calls 11

process_tokensFunction · 0.85
listdirMethod · 0.80
get_lineMethod · 0.80
get_msgMethod · 0.80
errprintFunction · 0.70
printFunction · 0.50
isdirMethod · 0.45
joinMethod · 0.45
openMethod · 0.45
get_linenoMethod · 0.45
closeMethod · 0.45

Tested by 1

__runMethod · 0.56