-
Notifications
You must be signed in to change notification settings - Fork 0
/
PFile.py
90 lines (90 loc) · 2.41 KB
/
PFile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import os
import console
seporaterbar = """
≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
"""
def main():
print("PFile")
print(seporaterbar)
print("[A] Edit file\n[B] Create file\n[C] Create and open file")
todo = input().upper()
if todo == "A":
console.clear()
todo = input("What file (include extentions like .txt or .py)\n")
console.clear()
f = open(todo,"r")
oldcontents = f.read()
contents = oldcontents
while todo != "exit":
console.clear()
if contents == oldcontents:
top = f"PFile - {todo}"
else:
top = f"PFile - {todo} - Edited"
print(top)
print(contents)
lolo = input()
if len(lolo) == 1:
contents = contents + lolo
else:
if lolo == "del":
contents = contents[:-1]
elif lolo == "delword":
words = contents.split(" ")
words.pop(-1)
contents = " ".join(words)
elif lolo == "delall":
contents = ""
elif lolo == "enter":
contents = contents + "\n"
elif lolo == "exit":
f.close()
f = open(todo,"w")
f.write(contents)
break
else:
contents = contents + lolo
elif todo == "B":
console.clear()
todo = input("What is the filename you are creating?\n")
f = open(todo,"x")
f.close()
elif todo == "C":
console.clear()
todo = input("What is the filename your are creating and opening?\n")
f = open(todo,"x")
f.close()
f = open(todo,"r")
oldcontents = f.read()
contents = oldcontents
while todo != "exit":
console.clear()
if contents == oldcontents:
top = f"PFile - {todo}"
else:
top = f"PFile - {todo} - Edited"
print(top)
print(contents)
lolo = input()
if len(lolo) == 1:
contents = contents + lolo
else:
if lolo == "del":
contents = contents[:-1]
elif lolo == "delword":
words = content.split(" ")
words.pop(-1)
content = " ".join(words)
elif lolo == "delall":
contents = ""
elif lolo == "enter":
contents = contents + "\n"
elif lolo == "exit":
f.close()
f = open(todo,"w")
f.write(contents)
break
else:
contents = contents + lolo
if __name__ == "__main__":
main()