@name: validateList @Description: 1. A utility function to validate whether the input passed is a list 2. The list is empty or not 3. If it is list and not empty, return PASS and first element 4. If not reason for FAIL @Inpu
(inp)
| 455 | return 'snapshot exists' in result |
| 456 | |
| 457 | def validateList(inp): |
| 458 | """ |
| 459 | @name: validateList |
| 460 | @Description: 1. A utility function to validate |
| 461 | whether the input passed is a list |
| 462 | 2. The list is empty or not |
| 463 | 3. If it is list and not empty, return PASS and first element |
| 464 | 4. If not reason for FAIL |
| 465 | @Input: Input to be validated |
| 466 | @output: List, containing [ Result,FirstElement,Reason ] |
| 467 | Ist Argument('Result') : FAIL : If it is not a list |
| 468 | If it is list but empty |
| 469 | PASS : If it is list and not empty |
| 470 | IInd Argument('FirstElement'): If it is list and not empty, |
| 471 | then first element |
| 472 | in it, default to None |
| 473 | IIIrd Argument( 'Reason' ): Reason for failure ( FAIL ), |
| 474 | default to None. |
| 475 | INVALID_INPUT |
| 476 | EMPTY_LIST |
| 477 | """ |
| 478 | ret = [FAIL, None, None] |
| 479 | if inp is None: |
| 480 | ret[2] = INVALID_INPUT |
| 481 | return ret |
| 482 | if not isinstance(inp, list): |
| 483 | ret[2] = INVALID_INPUT |
| 484 | return ret |
| 485 | if len(inp) == 0: |
| 486 | ret[2] = EMPTY_LIST |
| 487 | return ret |
| 488 | return [PASS, inp[0], None] |
| 489 | |
| 490 | def verifyElementInList(inp, toverify, responsevar=None, pos=0): |
| 491 | ''' |
no outgoing calls