Completed
Pull Request — master (#590)
by Anthony
03:29
created

GenericAction   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 11
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 9 4
1
from lib.action import CiscoSparkAction
2
3
__all__ = [
4
    'GenericAction'
5
]
6
7
8
class GenericAction(CiscoSparkAction):
9
10
    def run(self, accessor, method_name, **kwargs):
11
        a = getattr(self.connection, accessor)
12
        result = getattr(a, method_name)(**kwargs)
13
        if method_name == 'list':
14
            result = list(result)  # iterate generator
15
        if isinstance(result, list):
16
            return [x._json for x in result]
17
        else:
18
            return result._json
19