Conditions | 6 |
Total Lines | 18 |
Code Lines | 13 |
Lines | 18 |
Ratio | 100 % |
Tests | 1 |
CRAP Score | 34.317 |
Changes | 0 |
1 | #! /usr/bin/env python3 |
||
18 | 1 | View Code Duplication | def getString(key, key1=None): |
|
|||
19 | """ |
||
20 | Get a string from the string database. |
||
21 | """ |
||
22 | data = STRINGS[key] |
||
23 | if isinstance(data, list): |
||
24 | res = data[random.randint(0, len(data) - 1)] |
||
25 | elif isinstance(data, dict): |
||
26 | if key1 is None: |
||
27 | res = data |
||
28 | else: |
||
29 | res = data[key1] |
||
30 | if isinstance(res, list): |
||
31 | res = res[random.randint(0, len(res) - 1)] |
||
32 | elif isinstance(data, str): |
||
33 | res = data |
||
34 | |||
35 | return res |
||
36 | |||
76 |