Ask your own question, for FREE!
Computer Science 16 Online
OpenStudy (anonymous):

Python Help!!!!

OpenStudy (anonymous):

Here is the topic: The input Your program will take input from the console in the following format. It should not prompt the user in any way; it should simply read whatever input is typed into the console, and you should assume that your user knows the precise input format. A description of that format follows. The first line of the input is the path to the directory in which the search for files should be rooted. For example, a Windows user might type C:\Program Files or D:\Python34\Lib, in which case only files in or "underneath" the chosen directory will be found. If the first line of the input is not a valid path to a directory (e.g., not a path to a directory that exists, or is not a valid path at all), print the word ERROR on a line by itself and repeat reading a line of input; continue until the input is a valid path to a directory. The second line of the input specifies the search characteristics that will be used in deciding whether files are "interesting" and should have action taken on them. There are three different search characteristics; the second line of the input chooses one of them. If the second line of the input begins with the letter N, the search will be for files whose names exactly match a particular name. The N will be followed by space; after the space, the rest of the line will indicate the name of the files to be searched for. If the second line of the input begins with the letter E, the search will be for files whose name end in a particular extension. The E will be followed by a space; after the space, the rest of the line will indicate the desired extension. For example, if the desired extension is py, all files whose names end in .py will be considered interesting. The desired extension may be specified with or without a dot preceding it (e.g., E .py or E py would mean the same thing in the input), and your search should behave the same either way. Note, also, that there is a difference between what you might call a name ending and an extension. In our program, if the search is looking for files with the extension oc, a file named iliveinthe.oc would be found, but a file named invoice.doc would not. If the second line of the input begins with the letter S, the search will be for files whose size, measured in bytes, strictly exceeds (i.e., is greater than) a specified threshold. The S will be followed by a space; after the space, the rest of the line will be a non-negative integer value specifying the size threshold. For example, the input S 2097151 means that files whose sizes are at least 2,097,152 bytes (i.e., greater than 2,097,151 bytes) will be considered interesting. If the second line of the input does not match one of the formats described above, print the word ERROR on a line by itself and repeat reading a line of input; continue until the input is a valid path to a directory. The third line of the input specifies the action that should be taken on each of the interesting files found in the search. No matter what, you should always print the file's path, on its own line of output, to the console when you find an interesting one; the action chosen here specifies what else should be done with it. If the third line of the input contains the letter P by itself, print the file's path to the console — just as you will always do — but otherwise don't do anything with it. If the third line of the input contains the letter F by itself, open the file under the assumption that the file is a text read, read the first line of text from the file, and print that text to the console. (If the file does not contain text, it's fine if this choice prints unreadable garbage or even crashes your program; testing that a file is a text file is trickier than it sounds, so we'll only test this feature on text files.) If the third line of the input contains the letter D by itself, make a duplicate copy of the file and store it in the same directory where the original resides, but the copy should have .dup (short for "duplicate") appended to the filename. For example, if the interesting file is C:\pictures\boo.jpg, you would copy it to C:\pictures\boo.jpg.dup. If the third line of the input contains the letter T by itself, "touch" the file, which means to modify its last modified timestamp to be the current date/time. If the third line of the input does not match one of the formats described above, print the word ERROR on a line by itself and repeat reading a line of input; continue until the input is a valid path to a directory.

OpenStudy (e.mccormick):

Well, what problem are you having?

OpenStudy (anonymous):

the following attachment is the work I have now:

OpenStudy (anonymous):

the topic of this project is on the website:(look at ""The program""") http://www.ics.uci.edu/~thornton/ics32/ProjectGuide/Project1

OpenStudy (anonymous):

now i am having a trouble of finishing up the "third line of input"

OpenStudy (anonymous):

which is the line after this: #----------------------------------------------------------------------------------------------------------------------

OpenStudy (e.mccormick):

Well, what problem are you having with it?

OpenStudy (anonymous):

My question is: what should i put inside the ( ) for print_file_path() and read_file_print() and duplicate_file () and os.utime()

OpenStudy (anonymous):

should i put "Found_files" in print_file_path()? or ?

OpenStudy (e.mccormick):

Well, if you are storing the file name in a global, you do not need anything. But if it is a local variable then you probably want to pass the path that needs to be worked on.

OpenStudy (anonymous):

uh....i think its a local variable. i was wondering that should i put "Found_files" in print_file_path()

OpenStudy (e.mccormick):

Well, you are going to work on a file or multiple files, so those functions need to know about that. So whatver you are using to stor the path(s) needs to be passed to these functions so that they can do the work.

OpenStudy (anonymous):

ok....

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!