MetaStalk.modules.DateTime   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 42
dl 0
loc 69
ccs 22
cts 22
cp 1
rs 10
c 0
b 0
f 0
wmc 5

1 Function

Rating   Name   Duplication   Size   Complexity  
B date_time() 0 61 5
1
"""Makes a table that plots GPS timestamp or other timestamp metadata."""
2 1
import logging
3 1
import plotly.graph_objects as go
4
5 1
log = logging.getLogger("MetaStalk")
6
7
8 1
def date_time(photos: list) -> go.Figure():
9
    """date_time.
10
11
    Makes a table with timestamp of photos.
12
    There are three name that DateTime data can be under `Creation date`,
13
    `Date-time original`, `Date-time digitized` and a column in made
14
    for each type.
15
16
    Arguments:
17
        photos {list} -- A list of dictionaries with phot information.
18
19
    Returns:
20
        go.Figure -- A plotly Table with the DateTime data.
21
    """
22 1
    log.info("Starting DateTime Charts")
23 1
    datetime, datetime_original, datetime_digitized = [], [], []
24 1
    types = [datetime, datetime_original, datetime_digitized]
25 1
    types_str = [
26
        "Image DateTime",
27
        "EXIF DateTimeOriginal",
28
        "EXIF DateTimeDigitized",
29
        "GPS GPSDate",
30
    ]
31
32 1
    simple_photos = []
33 1
    for i, _ in enumerate(photos):
34 1
        simple_photos.append(photos[i]["item"])
35
36 1
    for each in photos:
37 1
        for i, _ in enumerate(types):
38 1
            try:
39 1
                date_type = str(each[types_str[i]]).replace(":", "/", 2)
40 1
                types[i].append(date_type)
41 1
                log.debug("%s has %s data", each["item"], types_str[i])
42 1
            except KeyError:
43 1
                log.info("%s has no %s data ", each["item"], types_str[i])
44
45 1
    fig = go.Figure(
46
        data=[
47
            go.Table(
48
                header=dict(
49
                    values=[
50
                        "Photo",
51
                        "Image DateTime",
52
                        "Date Time Original",
53
                        "Date Time Digitized",
54
                    ]
55
                ),
56
                cells=dict(
57
                    values=[
58
                        simple_photos,
59
                        datetime,
60
                        datetime_original,
61
                        datetime_digitized,
62
                    ]
63
                ),
64
            )
65
        ]
66
    )
67 1
    fig.update_layout(title="Timestamp Information", title_x=0.5)
68
    return fig
69