| Total Complexity | 6 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import sys |
||
|
|
|||
| 2 | import json |
||
| 3 | import logging |
||
| 4 | |||
| 5 | |||
| 6 | logging.basicConfig(stream=sys.stdout, level=logging.INFO) |
||
| 7 | #logger = logging.getLogger('LORISQuery') |
||
| 8 | |||
| 9 | |||
| 10 | def number_extraction(string): |
||
| 11 | """ |
||
| 12 | Return |
||
| 13 | :param string: |
||
| 14 | :return: a LIST of strings of number! |
||
| 15 | """ |
||
| 16 | import re |
||
| 17 | return re.findall(r'\d+', string) |
||
| 18 | |||
| 19 | if __name__ == '__main__': |
||
| 20 | print(number_extraction("T4")) |
||
| 21 | |||
| 22 | |||
| 23 | def is_response_success(status_code, expected_code): |
||
| 24 | """ |
||
| 25 | A simple function to determine the success of the status code |
||
| 26 | :param status_code: |
||
| 27 | :return: boolean value |
||
| 28 | """ |
||
| 29 | if status_code == expected_code: |
||
| 30 | return True |
||
| 31 | else: |
||
| 32 | return False |
||
| 33 | |||
| 34 | |||
| 35 | def check_json(data): |
||
| 36 | """ |
||
| 37 | Check if the data input is JSON format compatible. |
||
| 38 | :param data: |
||
| 39 | :return: |
||
| 40 | """ |
||
| 41 | try: |
||
| 42 | JSON = json.loads(data) |
||
| 43 | return True, JSON |
||
| 44 | except ValueError: |
||
| 45 | return False, None |
||
| 46 | except Exception as e: |
||
| 47 | return False, None |
||
| 48 |
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.