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

Function reformat_file

tools/python-3.11.9-amd64/Tools/scripts/pindent.py:418–429  ·  view source on GitHub ↗
(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS)

Source from the content-addressed store, hash-verified

416# end def delete_file
417
418def reformat_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS):
419 with open(filename, 'r') as f:
420 source = f.read()
421 # end with
422 result = reformat_string(source, stepsize, tabsize, expandtabs)
423 if source == result: return 0
424 # end if
425 make_backup(filename)
426 with open(filename, 'w') as f:
427 f.write(result)
428 # end with
429 return 1
430# end def reformat_file
431
432# Test program when called as a script

Callers

nothing calls this directly

Calls 5

reformat_stringFunction · 0.85
make_backupFunction · 0.85
openFunction · 0.50
readMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected