MCPcopy Create free account
hub / github.com/ActiveState/code / delete

Function delete

recipes/Python/464411_Profile_Cleanup/recipe-464411.py:15–25  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

13 print os.path.basename(sys.argv[0]), '<directory>'
14
15def delete(path):
16 for name in os.listdir(path):
17 path_name = os.path.join(path, name)
18 try:
19 if os.path.isdir(path_name):
20 delete(path_name)
21 os.rmdir(path_name)
22 elif os.path.isfile(path_name):
23 os.remove(path_name)
24 except:
25 print 'ERROR:', path_name
26
27if __name__ == '__main__':
28 main(r'C:\Documents and Settings\SCHAP472')

Callers 1

mainFunction · 0.70

Calls 6

isdirMethod · 0.80
rmdirMethod · 0.80
isfileMethod · 0.80
listdirMethod · 0.45
joinMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected