Skip to content

Commit 6a7fb34

Browse files
author
Aiden Scandella
committed
whitespace cleanup
1 parent 6896091 commit 6a7fb34

File tree

3 files changed

+16
-20
lines changed

3 files changed

+16
-20
lines changed

Socrata.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from urllib import urlencode
2121
from urlparse import urljoin
2222

23-
id_pattern= re.compile('^[0-9a-z]{4}-[0-9a-z]{4}$')
23+
id_pattern = re.compile('^[0-9a-z]{4}-[0-9a-z]{4}$')
2424

2525

2626
class SocrataBase:
@@ -32,10 +32,10 @@ def __init__(self, host, username, password, app_token):
3232
options specified in standard ConfigParser format
3333
"""
3434

35-
self.username = username
36-
self.password = password
37-
self.host = host
38-
self.app_token=app_token
35+
self.username = username
36+
self.password = password
37+
self.host = host
38+
self.app_token = app_token
3939

4040
def _request(self, service, type='GET', data = {}, files=dict()):
4141
"""Generic HTTP request, encoding data as JSON and decoding the response"""
@@ -48,9 +48,9 @@ def _request(self, service, type='GET', data = {}, files=dict()):
4848
del headers['Content-type']
4949

5050
if data:
51-
data_json=json.dumps(data)
51+
data_json = json.dumps(data)
5252
else:
53-
data_json=None
53+
data_json = None
5454

5555
response= client(uri,
5656
headers = headers,
@@ -172,8 +172,8 @@ def attach_file(self, filename):
172172
self._request("/views/%s.json" % self.id, 'PUT', {'metadata':metadata})
173173

174174
def multipart_post(self, url, filename, field='file'):
175-
file_to_upload=open(filename, "rb")
176-
response= self._request(url, type='POST', files={filename:file_to_upload })
175+
file_to_upload = open(filename, "rb")
176+
response = self._request(url, type='POST', files={filename:file_to_upload })
177177
return response
178178

179179

rss_capturer.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def create_dataset_with_columns(dataset, title = 'RSS Feed Dataset', description
2424
dataset.add_column('Title', '', 'text', False, False, 300)
2525
dataset.add_column('URL', '', 'url', False, False, 300)
2626
dataset.add_column('Date', '', 'date')
27-
27+
2828
return
2929

3030
if __name__ == "__main__":
@@ -36,14 +36,13 @@ def create_dataset_with_columns(dataset, title = 'RSS Feed Dataset', description
3636
print "Downloading RSS feed from " + str(feed_url)
3737

3838
rss = feedparser.parse(feed_url)
39-
4039
cfg = ConfigParser.ConfigParser()
4140
cfg.read('socrata.cfg')
42-
43-
host=cfg.get('server', 'host')
44-
username=cfg.get('credentials', 'user')
45-
password= cfg.get('credentials', 'password')
46-
app_token= cfg.get('credentials', 'app_token')
41+
42+
host = cfg.get('server', 'host')
43+
username = cfg.get('credentials', 'user')
44+
password = cfg.get('credentials', 'password')
45+
app_token = cfg.get('credentials', 'app_token')
4746

4847
dataset = Socrata.Dataset( host, username, password, app_token)
4948

@@ -66,10 +65,9 @@ def create_dataset_with_columns(dataset, title = 'RSS Feed Dataset', description
6665
data['Title'] = item.title
6766
data['URL'] = item.link
6867
if hasattr(item,'date_parsed'):
69-
data['Date'] = time.strftime("%m/%d/%Y %H:%M:%S", item.date_parsed)
68+
data['Date'] = time.strftime("%m/%d/%Y %H:%M:%S", item.date_parsed)
7069
batch_requests.append(dataset.add_row_delayed(data))
7170

72-
7371
dataset._batch(batch_requests)
7472
print "You can now view the dataset:"
7573
print dataset.short_url()

socrata.cfg-dist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,3 @@ app_token: xxxxxxxxxxxxxxxxxxxxx (application token created in your account prof
55

66
[server]
77
host: https://opendata.socrata.com
8-
api_host: https://opendata.socrata.com/api
9-

0 commit comments

Comments
 (0)