Code Duplication    Length = 18-18 lines in 2 locations

marvin_actions.py 1 location

@@ 57-74 (lines=18) @@
54
    STRINGS = json.load(f)
55
56
57
def getString(key, key1=None):
58
    """
59
    Get a string from the string database.
60
    """
61
    data = STRINGS[key]
62
    if isinstance(data, list):
63
        res = data[random.randint(0, len(data) - 1)]
64
    elif isinstance(data, dict):
65
        if key1 is None:
66
            res = data
67
        else:
68
            res = data[key1]
69
            if isinstance(res, list):
70
                res = res[random.randint(0, len(res) - 1)]
71
    elif isinstance(data, str):
72
        res = data
73
74
    return res
75
76
77
def marvinSmile(row):

marvin_general_actions.py 1 location

@@ 18-35 (lines=18) @@
15
lastDateGreeted = None
16
17
18
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
37
38
def getAllGeneralActions():