MCPcopy Index your code
hub / github.com/python/cpython / process

Function process

Tools/patchcheck/untabify.py:27–51  ·  view source on GitHub ↗
(filename, tabsize, verbose=True)

Source from the content-addressed store, hash-verified

25
26
27def process(filename, tabsize, verbose=True):
28 try:
29 with tokenize.open(filename) as f:
30 text = f.read()
31 encoding = f.encoding
32 except IOError as msg:
33 print("%r: I/O error: %s" % (filename, msg))
34 return 2
35 newtext = text.expandtabs(tabsize)
36 if newtext == text:
37 return 0
38 backup = filename + "~"
39 try:
40 os.unlink(backup)
41 except OSError:
42 pass
43 try:
44 os.rename(filename, backup)
45 except OSError:
46 pass
47 with open(filename, "w", encoding=encoding) as f:
48 f.write(newtext)
49 if verbose:
50 print(filename)
51 return 1
52
53
54if __name__ == '__main__':

Callers 2

mainFunction · 0.85
_iter_filenamesFunction · 0.85

Calls 7

openFunction · 0.50
openMethod · 0.45
readMethod · 0.45
expandtabsMethod · 0.45
unlinkMethod · 0.45
renameMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…