Skip to content

Commit 4ec73c4

Browse files
committed
Merge pull request #15 from yasoob/master
Pylint rating is 9.83/10
2 parents 6594345 + 99630c0 commit 4ec73c4

File tree

1 file changed

+28
-16
lines changed

1 file changed

+28
-16
lines changed

loklak.py

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,13 @@ def geocode(self, places=None):
6161
return_to_user = {}
6262
return json.dumps(return_to_user)
6363

64-
def get_map(self, latitude, longitude, width=500, height=500, zoom=8, text=""):
64+
def get_map(self, latitude, longitude, width=500, height=500,
65+
zoom=8, text=""):
6566
"""Returns a map of size 500x500"""
6667
map_application = 'vis/map.png'
67-
params = {'text': text, 'mlat': latitude, 'mlon': longitude,\
68+
params = {'text': text, 'mlat': latitude, 'mlon': longitude,
6869
'width': width, 'height': height, 'zoom': zoom}
69-
return_to_user = requests.get(self.baseUrl + map_application, \
70+
return_to_user = requests.get(self.baseUrl + map_application,
7071
params=params, stream=True)
7172
if return_to_user.status_code == 200:
7273
return return_to_user.raw.read()
@@ -108,7 +109,8 @@ def user(self, name=None, followers=None, following=None):
108109
return json.dumps(return_to_user)
109110
else:
110111
return_to_user = {}
111-
return_to_user['error'] = 'No user name given to query. Please check and try again'
112+
return_to_user['error'] = ('No user name given to query. Please '
113+
'check and try again')
112114
return json.dumps(return_to_user)
113115

114116
def settings(self):
@@ -146,21 +148,24 @@ def search(self, query=None, since=None, until=None, from_user=None):
146148
return return_to_user.json()
147149
else:
148150
return_to_user = {}
149-
return_to_user['error'] = 'Something went wrong, Looks like the server is down.'
151+
return_to_user['error'] = ('Something went wrong, Looks like'
152+
' the server is down.')
150153
return json.dumps(return_to_user)
151154
else:
152155
return_to_user = {}
153-
return_to_user['error'] = 'No Query string has been given to run a query for'
156+
return_to_user['error'] = ('No Query string has been'
157+
' given to run a query for')
154158
return json.dumps(return_to_user)
155159

156-
def aggregations(self, query=None, since=None, until=None, fields=None, limit=None):
160+
def aggregations(self, query=None, since=None, until=None,
161+
fields=None, limit=None):
157162
"""Gives the aggregations of the application"""
158163
aggregations_application = 'api/search.json'
159164
url_to_give = self.baseUrl+aggregations_application
160165
self.query = query
161166
self.since = since
162167
self.until = until
163-
self.fields = fields # Array seperated values to be passed
168+
self.fields = fields
164169
self.limit = limit
165170
if query:
166171
params = {}
@@ -172,7 +177,7 @@ def aggregations(self, query=None, since=None, until=None, fields=None, limit=No
172177
if fields:
173178
field_string = ''
174179
for i in self.fields:
175-
field_string += i +','
180+
field_string += i + ','
176181
params['fields'] = field_string
177182
if limit:
178183
params['limit'] = self.limit
@@ -186,7 +191,8 @@ def aggregations(self, query=None, since=None, until=None, fields=None, limit=No
186191
return return_to_user
187192
else:
188193
return_to_user = {}
189-
return_to_user['error'] = 'Something went wrong, Looks like the server is down.'
194+
return_to_user['error'] = ('Something went wrong, '
195+
'Looks like the server is down.')
190196
return json.dumps(return_to_user)
191197
else:
192198
return_to_user = {}
@@ -203,32 +209,38 @@ def account(self, name=None, action=None, data=None):
203209
self.action = action
204210
# Simple GET Query
205211
headers = {
206-
'User-Agent': 'Mozilla/5.0 (Android 4.4; Mobile; rv:41.0) Gecko/41.0 Firefox/41.0',
212+
'User-Agent': ('Mozilla/5.0 (Android 4.4; Mobile; rv:41.0)'
213+
' Gecko/41.0 Firefox/41.0'),
207214
208215
}
209216
if name:
210217
params = {}
211218
params['screen_name'] = self.name
212-
return_to_user = requests.get(url_to_give, params=params, headers=headers)
219+
return_to_user = requests.get(url_to_give, params=params,
220+
headers=headers)
213221
if return_to_user.status_code == 200:
214222
return return_to_user.json()
215223
else:
216224
return_to_user = {}
217-
return_to_user['error'] = 'Something went wrong, Looks query is wrong.'
225+
return_to_user['error'] = ('Something went wrong, '
226+
'Looks query is wrong.')
218227
return json.dumps(return_to_user)
219228
# if action = update and data is provided, then make request
220229
elif self.action == 'update' and data:
221230
params = {}
222231
params['action'] = self.action
223232
params['data'] = self.data
224-
return_to_user = requests.post(url_to_give, params=params, headers=headers)
233+
return_to_user = requests.post(url_to_give,
234+
params=params, headers=headers)
225235
if return_to_user.status_code == 200:
226236
return return_to_user.json()
227237
else:
228238
return_to_user = {}
229-
return_to_user['error'] = 'Something went wrong, Looks query is wrong.'
239+
return_to_user['error'] = ('Something went wrong,'
240+
' Looks query is wrong.')
230241
return json.dumps(return_to_user)
231242
else:
232243
return_to_user = {}
233-
return_to_user['error'] = 'No Query string has been given to run an query for account'
244+
return_to_user['error'] = ('No Query string has been given'
245+
' to run an query for account')
234246
return json.dumps(return_to_user)

0 commit comments

Comments
 (0)