repl.it
@paulfears/

FileSystem

Python

No description

fork
loading
Files
  • main.py
  • root
  • app.py
  • beta.py
  • Colors.py
  • do.py
  • do.txt
  • funct.txt
  • Packager files
  • poetry.lock
  • pyproject.toml
  • requirements.txt
main.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
import replit
from do import Do
import re
import os
import subprocess
import shutil
from Colors import *
from app import *
import app
import time
open("funct.txt", "w").write("")
a=input("Would you like to try the beta version (Yes or No): ")
if a.lower()=="yes":
  exec(open("/home/runner/beta.py").read())
SU = False
try:
  os.makedirs("root")
  os.chdir("root")
  os.makedirs("user")
  os.chdir("/home/runner")
except FileNotFoundError:
  shutil.rmtree("root")
  os.makedirs("root")
  os.chdir("root")
  os.makedirs("user")
os.chdir("/home/runner")

def start():
  replit.clear()
  while True:
    others=open("/home/runner/funct.txt").read()
    path=os.getcwd()[12:]
    done=0
    a=input(Green+os.getcwd()[12:]+" $ "+Blue)
    print(Reset, end="")
    argv=a.split(" ")
    com=argv[0]
    if a=="":
      pass
    if com=="yes":
      os.system("yes")
      done=1
    if com=="mkdir":
      if len(argv)==2:
        os.makedirs(argv[1])
      else:
        print(Red+"Invalid number of arguments.")
      done=1
    if com=="mkf":
      if len(argv)==2:
        open(argv[1], "w+")
      else:
        print(Red+"Invalid number of arguments.")
      done=1
    if com=="pwd":
      print(Reset+os.getcwd()[12:])
      done=1
    if com == "ls":
      print(Reset, end="")
      for i in os.listdir():
        print(i)
      done=1
    if com == "rm":
      done=1
      if len(argv)==2:
        if argv[1].find("/") == -1:
          try:
            os.remove(argv[1])
          except IsADirectoryError:
            shutil.rmtree(argv[1])
        else:
          os.remove(de+argv[1])
      else:
        print(Red+"Invalid number of arguments.")
    if com =="mv":
      if len(argv)==3:
        shutil.move(argv[1], argv[2])
      else: 
        print(Red+"Invalid number of arguments.")
    if com=="cp":
      if len(argv)==3:
        shutil.copy2(argv[1], argv[2])
      else:
        print(Red+"Invalid number of arguments.")
    if com=="exit":
      sys.exit()
      done=1
    if com == "help":
      done=1
      print(Reset+"""
mkdir - Make a new directory
mkf - Make a new file
pwd - Shows the current path
help - lists commands and their uses
ls - lists all files and directories in the current directory
mv - move
cp - copy
exit - exit
cd - change directory
fedit - used for editing files
eracf - erases a file
openf - reads a file
echo - prints 1st argument
apps - view and use applications
python - interactive python interpreter
c++ - compile c++ file
./ - execute a file
clear - clears the screen
      """)
    if com == "cd":
      if len(argv)==2:
        if argv[1].find("./") != -1:
          if path!="":
            os.chdir(de+"/"+path.split("/")[-2])
          else:
            print(Red+"Error: System can't exit this direcory: no other directory.")
        else:
          if argv[1].find("/") != -1:
            os.chdir(de+"/"+argv[1])
          else:
            os.chdir(de+os.getcwd()[12:]+"/"+argv[1])
      else:
        print(Red+"Invalid number of arguments.")
      done=1
    if com == "fedit":
      done=1
      if len(argv)==2:
        new=""
        toedit = de+os.getcwd()[12:]+"/"+argv[1]
        try:
          open(toedit).read()
        except:
          print(Red+"That file does not exist")
          new="exit()"
        if new != "exit()":
          print(Reset+"Type exit() to exit")
          while new!="exit()":
            line=len(open(toedit).read().splitlines())+1
            new=input("{0}: ".format(line))
            if new=="exit()":
              break
            open(toedit, "a").write(new+"\n")
            line+=1
      else:
        print(Red+"Invalid number of arguments.")
    if com == "openf":
      done=1
      if len(argv)==2:
        print(Reset+open(de+os.getcwd()[12:]+"/"+argv[1]).read())
      else:
        print(Red+"Invalid number of arguments.")
    if com == "eracf":
      done=1
      if len(argv)==2:
        toedit = de+os.getcwd()[12:]+"/"+argv[1]
        f=open(toedit, "w").write("")
      else:
        print(Red+"Invalid number of arguments.")
    if com == "echo":
      done=1
      if len(argv)==2:
        print(Reset+argv[1])
      else:
        print()
    if com=="apps":
      print(Reset+"""
1) Timer
2) Stopwatch
      """)
      a=input("> ")
      if a=="1":
        done=1
        timer(int(input("How long would you like the timer to last: ")))
      if a=="2":
        start = time.time()
        a=input("Press Enter when done.")
        stopwatch(start, time.time())
      else:
        print(Red+"Error Expected Option 1-3 Error")
    if com=="python":
      a=""
      for i in argv[1:]:
        a+=" "+i
      os.system(com+a)
      done=1
    if com=="c++":
      done=1
      a=""
      for i in argv[1:]:
        a+=" "+i
      os.system("c++"+a)
    if com.startswith("./") != False:
      os.system(a)
      done=1
    if com=="clear":
      replit.clear()
    if com=="function":
      done=1
      open(de+"/funct.txt", "a").write(argv[1]+"{\n")
      i=""
      print(Reset+"\"end\" goes at the end of a function")
      while i != "end":
        i=input("... ")
        if i!="end":
          open(de+"/funct.txt", "a").write(i+"\n")
        else:
          open(de+"/funct.txt", "a").write(i)
      open(de+"/funct.txt", "a").write("}\n")
    else:
      if re.search(com+"{\n", others) == None and com != "":
        if done!=1:
          print(Red+"\"{0}\": command not found.".format(com))
          done=1
      else:
        code=others.find(com+"{\n")+len(com)+1
        others=others[code:others.find("end}", code)]
        others=others.splitlines()
        for a in others:
          Do(a)
          #fix this
        done=1
while True:
  start()
?