Completed
Push — master ( 16fc24...51a4d2 )
by Thomas
8s
created

doorpi.status.status_lib.get()   B

Complexity

Conditions 5

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 5
dl 0
loc 13
rs 8.5454
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
4
import logging
5
logger = logging.getLogger(__name__)
6
logger.debug("%s loaded", __name__)
7
8
def get(*args, **kwargs):
0 ignored issues
show
Unused Code introduced by Thomas
The argument args seems to be unused.
Loading history...
9
    try:
10
        if len(kwargs['name']) == 0: kwargs['name'] = ['']
11
        if len(kwargs['value']) == 0: kwargs['value'] = ['']
12
13
        filter = kwargs['name'][0]
0 ignored issues
show
Bug Best Practice introduced by Thomas
This seems to re-define the built-in filter.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
14
        try: max_count = int(kwargs['value'][0])
15
        except: max_count = 100
16
17
        return kwargs['DoorPiObject'].event_handler.db.get_event_log_entries(max_count, filter)
18
    except Exception as exp:
19
        logger.exception(exp)
20
        return {'Error': 'could not create '+str(__name__)+' object - '+str(exp)}
21
22
def is_active(doorpi_object):
23
    if len(doorpi_object.event_handler.db.get_event_log_entries(1, '')):
24
        return True
25
    else:
26
        return False
27