Passed
Push — master ( cb8661...b33fcc )
by Cyb3r
07:37 queued 11s
created

MetaStalk.modules.DateTime   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 32
dl 0
loc 54
rs 10
c 0
b 0
f 0
wmc 5

1 Function

Rating   Name   Duplication   Size   Complexity  
B date_time() 0 46 5
1
"""Makes a table that plots gps timestamp"""
2
import logging
3
import plotly.graph_objects as go
4
5
log = logging.getLogger("MetaStalk")
6
7
8
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
    log.info("Starting DateTime Charts")
23
    datetime = []
24
    datetime_original = []
25
    datetime_digitized = []
26
    types = [datetime, datetime_original, datetime_digitized]
27
    types_str = ["Creation date", "Date-time original", "Date-time digitized"]
28
29
    simple_photos = []
30
    for i, _ in enumerate(photos):
31
        simple_photos.append(photos[i]["item"])
32
33
    for each in photos:
34
        for i, _ in enumerate(types):
35
            try:
36
                types[i].append(each[types_str[i]])
37
                log.debug("%s has %s data", each["item"], types_str[i])
38
            except KeyError:
39
                log.debug("%s has no %s data ", each["item"], types_str[i])
40
41
    fig = go.Figure(
42
        data=[go.Table(
43
            header=dict(values=[
44
                "Photos",
45
                "Creation date",
46
                "Date time Original",
47
                "Date time Digitized"
48
            ]),
49
            cells=dict(values=[simple_photos, datetime, datetime_original,
50
                               datetime_digitized]))]
51
    )
52
53
    return fig
54