Checks for file existence and readability >>> checkFile(__file__) True
(filename, raiseOnError=True)
| 1359 | return re.search(r"\A[0-9]+\Z", value or "") is not None |
| 1360 | |
| 1361 | def checkFile(filename, raiseOnError=True): |
| 1362 | """ |
| 1363 | Checks for file existence and readability |
| 1364 | |
| 1365 | >>> checkFile(__file__) |
| 1366 | True |
| 1367 | """ |
| 1368 | |
| 1369 | valid = True |
| 1370 | |
| 1371 | if filename: |
| 1372 | filename = filename.strip('"\'') |
| 1373 | |
| 1374 | if filename == STDIN_PIPE_DASH: |
| 1375 | return checkPipedInput() |
| 1376 | else: |
| 1377 | try: |
| 1378 | if filename is None or not os.path.isfile(filename): |
| 1379 | valid = False |
| 1380 | except: |
| 1381 | valid = False |
| 1382 | |
| 1383 | if valid: |
| 1384 | try: |
| 1385 | with open(filename, "rb"): |
| 1386 | pass |
| 1387 | except: |
| 1388 | valid = False |
| 1389 | |
| 1390 | if not valid and raiseOnError: |
| 1391 | raise SqlmapSystemException("unable to read file '%s'" % filename) |
| 1392 | |
| 1393 | return valid |
| 1394 | |
| 1395 | def banner(): |
| 1396 | """ |
no test coverage detected
searching dependent graphs…