MCPcopy Index your code
hub / github.com/geekcomputers/Python / main

Function main

check_file.py:34–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32
33
34def main():
35 # Check the arguments passed to the script
36 if len(sys.argv) >= 2:
37 file_names = sys.argv[1:]
38 filteredfilenames_1 = list(
39 file_names
40 ) # To counter changing in the same list which you are iterating
41 filteredfilenames_2 = list(file_names)
42 # Iterate for each filename passed in command line argument
43 for filename in filteredfilenames_1:
44 if not os.path.isfile(filename): # Check the File exists
45 print("[-] " + filename + " does not exist.")
46 filteredfilenames_2.remove(
47 filename
48 ) # remove non existing files from fileNames list
49 continue
50
51 # Check you can read the file
52 if not os.access(filename, os.R_OK):
53 print("[-] " + filename + " access denied")
54 # remove non readable fileNames
55 filteredfilenames_2.remove(filename)
56 continue
57
58 # Read the content of each file that both exists and is readable
59 for filename in filteredfilenames_2:
60 # Display Message and read the file contents
61 print("[+] Reading from : " + filename)
62 readfile(filename)
63
64 else:
65 usage() # Print usage if not all parameters passed/Checked
66
67
68if __name__ == "__main__":

Callers 1

check_file.pyFile · 0.70

Calls 3

readfileFunction · 0.85
usageFunction · 0.85
removeMethod · 0.45

Tested by

no test coverage detected