Passed
Push — master ( f4e57c...929827 )
by Cyb3r
01:59 queued 11s
created

MetaStalk.modules.Stats.stats()   A

Complexity

Conditions 2

Size

Total Lines 26
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 15
nop 2
dl 0
loc 26
ccs 9
cts 9
cp 1
crap 2
rs 9.65
c 0
b 0
f 0
1
"""Creates a table figure that shows
2
 photos that did and did not have exif"""
3 1
import logging
4 1
import plotly.graph_objects as go
5
6 1
log = logging.getLogger("MetaStalk")
7
8
9 1
def stats(photos: list, invalid: list) -> go.Figure():
10
    """Stats
11
12
    Creates the table of photos showing ones with metadata and ones without
13
14
    Arguments:
15
        photos {list} -- List of photos with metadata.
16
        invalid {list} -- List of photos without metadata.
17
18
    Returns:
19
        go.Figure() -- A plotly table
20
    """
21 1
    log.info("Staring Stats")
22 1
    log.debug("There are %s photos with metadata and %s without",
23
              len(photos), len(invalid))
24 1
    simple_photos = []
25 1
    for i, _ in enumerate(photos):
26 1
        simple_photos.append(photos[i]["item"])
27 1
    fig = go.Figure(
28
        data=[go.Table(
29
            header=dict(values=[
30
                "Photos with Metadata",
31
                "Photos without Metadata"]),
32
            cells=dict(values=[simple_photos, invalid]))])
33 1
    fig.update_layout(title="Photos With and Without Metadata.", title_x=0.5)
34
    return fig
35