def file(operation, path):
operation = operation.lower()
if operation == 'exists':
import os.path
return bool(os.path.isfile(path))
elif operation == 'read':
if file('exists', path):
F = open(path, "w")
return F
else:
raise RuntimeError('An Error Has Occured: File Not Found (0012)')
elif operation == 'delete':
import os
if file('exists', path):
os.remove(path)
else:
raise RuntimeError('An Error Has Occured: File Not Found (0012)')
elif operation == 'create':
if not file('exists', path):
f = open(path, "w+")
f.close()
else:
raise RuntimeError('An Error Has Occured: File Already Exists (0013)')
else:
raise RuntimeError('An Error Has Occured: Invalid Operation Entered (0008)')
# Tools For Text Files
评论列表
文章目录