subject

I need help with coding in python! class CommandLine:

def __init__(self):

self. root = Directory('', None)

self. current_path = self. root

def run(self):

command = input('>>> ')

while command. strip().lower() != 'exit':

split_command = command. split()

if len(split_command):

if split_command[0] == 'ls':

self. current_path. display()

if len(split_command) >= 2:

if split_command[0] == 'cd':

self. change_directory(split_command[1])< br />
elif split_command[0] == 'makedir':

self. current_path. create_directory(split_command[1])< br />
elif split_command[0] == 'fcreate':

self. current_path. create_file(split_command[1])

elif split_command[0] == 'fwrite':

self. current_path. file_write(split_command[1])

elif split_command[0] == 'fread':

self. current_path. file_read(split_command[1])

elif split_command[0] == 'fclose':

self. current_path. close_file(split_command[1])

elif split_command[0] == 'fopen':

self. current_path. open_file(split_command[1])

command = input('>>> ')

def change_directory(self, dir_name):

pass

class Directory:

def __init__(self, name, parent):

pass

def display(self):

pass

def create_file(self, file_name):

pass

def create_directory(self, dir_name):

pass

def file_write(self, file_name):

pass

def file_read(self, file_name):

pass

def close_file(self, file_name):

pass

def open_file(self, file_name):

pass

class File:

pass

if __name__ == '__main__':

cmd_line = CommandLine()

cmd_line. run()
You must keep track of your current directory, and then you must be able to execute the commands listed below.

(The commands are explicitly different from linux so that you don't accidentally execute them in the shell, except for ls and cd which are harmless.)

Command

ls
Lists contents of the directory
cd [dirname]
Change directory up or down one level.
makedir [dirname]
Make a directory
fcreate [filename]
Creates a file, sets it closed.
fwrite [filename]
Write to a file, only if it's open.
fread [filename]
Read a file, even if it's closed.
fclose [filename]
Close a file. Prevents write.
fopen [filename]
Open a file. Reset the contents

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 19:40
Microsoft introduced active directory with windows 2000. in server 2012, it is in now version 4. what are some new features in the new ad that were not present in windows 2000 ad?
Answers: 1
question
Computers and Technology, 22.06.2019 16:30
Primary tech skills are skills that are necessary for success in online education
Answers: 3
question
Computers and Technology, 23.06.2019 17:30
Per the municipal solid waste report, what are the most common sources of waste (trash
Answers: 3
question
Computers and Technology, 24.06.2019 15:30
Python. primary u.s. interstate highways are numbered 1-99. odd numbers (like the 5 or 95) go north/south, and evens (like the 10 or 90) go east/west. auxiliary highways are numbered 100-999, and service the primary highway indicated by the rightmost two digits. thus, the 405 services the 5, and the 290 services the 90. given a highway number, indicate whether it is a primary or auxiliary highway. if auxiliary, indicate what primary highway it serves. also indicate if the (primary) highway runs north/south or east/west.
Answers: 1
You know the right answer?
I need help with coding in python! class CommandLine:

def __init__(self):

s...
Questions
question
Chemistry, 21.09.2020 17:01
question
English, 21.09.2020 17:01
question
Mathematics, 21.09.2020 17:01
question
Mathematics, 21.09.2020 17:01
question
Mathematics, 21.09.2020 17:01
Questions on the website: 13722361