Projekt

Obecné

Profil

Stáhnout (790 Bajtů) Statistiky
| Větev: | Revize:
1
from typing import Dict
2

    
3
SKIP = "SKIP"
4
UNKNOWN = "UNKNOWN!"
5

    
6

    
7
def should_skip(device: Dict[str, str]) -> bool:
8
    return device['x'] == SKIP or device['y'] == SKIP or device[
9
        'x'] == UNKNOWN or device['y'] == UNKNOWN
10

    
11

    
12
def detect_change(first: Dict[str, str], second: Dict[str, str],
13
                  compareKeys: [str]) -> bool:
14
    """Detects change between two dictonaries
15

    
16
    Args:
17
        first (Dict[str, str]): First dictionary
18
        second (Dict[str, str]): Second dictionary
19
        compareKeys ([type]): Keys to handle comparison
20

    
21
    Returns:
22
        bool: Is there a change ?
23
    """
24
    for key in compareKeys:
25
        if key not in second or key not in first:
26
            return True
27
        if first[key] != second[key]:
28
            return True
29
    return False
(4-4/4)