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, 22.06.2019 13:30
1. technician a says horsepower information can be used by consumers to compare the power of different automobile engines. technician b says that manufacturers will often list the horsepower output of their engines in the online service information. who is right?
Answers: 2
question
Computers and Technology, 22.06.2019 20:00
What statement best describes operating systems? it’s possible for modern computers to function without operating systems. most operating systems are free or very inexpensive. operating systems are managed by the computer’s microprocessor (cpu). operating systems manage the computer’s random access memory (ram).
Answers: 1
question
Computers and Technology, 23.06.2019 02:00
Which demographic challenge is europe currently experiencing? a. an aging and decreasing population b. a baby boomc. an unequal distribution between males and females d. a large group of teenagers moving through the school system(i chose a but i'm unsure)
Answers: 1
question
Computers and Technology, 23.06.2019 11:00
What are the possible consequences of computer hacking? what is computer piracy? describe some examples. what are the effects of computer piracy? what are the possible consequences of computer piracy? what is intentional virus setting? describe some examples. what are the effects of intentional virus setting? what are the possible consequences of intentional virus setting? what is invasion of privacy? describe some examples. what are the effects of invasion of privacy? what are the possible consequences of invasion of privacy? what is an acceptable use policy and what is the purpose of the acceptable use policy what is intellectual property and how can you use it?
Answers: 1
You know the right answer?
I need help with coding in python! class CommandLine:

def __init__(self):

s...
Questions
question
Advanced Placement (AP), 20.04.2020 23:27
question
Mathematics, 20.04.2020 23:27
Questions on the website: 13722367