(filename, term)
| 197 | |
| 198 | # parser module for module and term |
| 199 | def module_parser(filename, term): |
| 200 | # if the file exists |
| 201 | if os.path.isfile(filename) and not "install_update_all" in filename and ".py" in filename and not ".pyc" in filename: |
| 202 | |
| 203 | # set a base counter |
| 204 | counter = 0 |
| 205 | |
| 206 | # open the file |
| 207 | fileopen = open(filename, "r") |
| 208 | # iterate through the file |
| 209 | for line in fileopen: |
| 210 | # strip any bogus stuff |
| 211 | line = line.rstrip() |
| 212 | # if the line starts with the term |
| 213 | if line.startswith(term): |
| 214 | line = line.replace(term + '="', "") |
| 215 | line = line.replace(term + "='", "") |
| 216 | line = line.replace(term + "=", "") |
| 217 | if str(line).endswith('"'): line = line[:-1] |
| 218 | if str(line).endswith("'"): line = line[:-1] |
| 219 | # reflect we hit this and our search term was found |
| 220 | counter = 1 |
| 221 | return line |
| 222 | |
| 223 | # if there was no search term identified for the module |
| 224 | if counter == 0: |
| 225 | filename_short = filename.replace(definepath() + "/", "") |
| 226 | filename_short = filename_short.replace(".py", "") |
| 227 | if term not in "BYPASS_UPDATE|LAUNCHER|TOOL_DEPEND|X64_LOCATION|install_update_all|FEDORA|OPENBSD|ARCHLINUX": |
| 228 | if filename_short not in "__init__|msfdb.sh|modules/custom_list/list": |
| 229 | print_error("Warning, module %s was found but contains no %s field." % (filename_short, term)) |
| 230 | print_error("Check the module again for errors and try again.") |
| 231 | print_error("Module has been removed from the list.") |
| 232 | |
| 233 | return "" |
| 234 | |
| 235 | # if the file isn't there |
| 236 | if not os.path.isfile(filename): |
| 237 | return None |
| 238 | |
| 239 | # help menu for PTF |
| 240 | def show_help_menu(): |
no test coverage detected