Completed
Push — master ( 32acac...19ae40 )
by Lakshmi
11:34
created

GetSearchResultsAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 8
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 7 2
1
import json
2
3
from google import google
4
5
from st2actions.runners.pythonrunner import Action
6
7
from lib.formatters import google_result_to_dict
8
9
__all__ = [
10
    'GetSearchResultsAction'
11
]
12
13
14
class GetSearchResultsAction(Action):
15
    def run(self, query, count=10):
16
        num_page = 1
17
18
        results = google.search(query, num_page)[:count]
19
        result = [google_result_to_dict(obj=obj) for obj in results]
20
        result = json.dumps(result)
21
        return result
22