Skip to content

Commit 8d53edd

Browse files
committed
minor cosmetic changes, bump to version v1.0.1 ❗
1 parent 9538fcd commit 8d53edd

File tree

7 files changed

+48
-58
lines changed

7 files changed

+48
-58
lines changed

setup.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
setup(
1212
name = 'simplegist',
1313
packages = ['simplegist'],
14-
version = '1.0.0',
14+
version = '1.0.1',
1515
install_requires=required,
1616
description = 'Python wrapper for Gist ',
1717
long_description=open('README.rst').read(),
1818
author = 'Varun Malhotra',
1919
author_email = '[email protected]',
20-
url = 'https://github.com/softvar/GistApi-Wrapper-python',
21-
download_url = 'https://github.com/softvar/GistApi-Wrapper-python/tarball/1.0.0',
20+
url = 'https://github.com/softvar/simplegist',
21+
download_url = 'https://github.com/softvar/simplegist/tarball/1.0.1',
2222
keywords = ['gist', 'github', 'API'],
2323
license = 'MIT',
2424
classifiers = (

simplegist/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
from simplegist import *
99

1010
__author__ = 'Varun Malhotra'
11-
__version__ = '0.3'
11+
__version__ = '1.0.1'
1212
__license__ = 'MIT'

simplegist/comments.py

+11-15
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
BASE_URL = 'https://api.github.com'
2-
GIST_URL = 'https://gist.github.com'
3-
41
import json
52
import requests
6-
7-
3+
from config import BASE_URL, GIST_URL
84

95
class Comments:
106
def __init__(self, gist):
117
self.gist = gist
12-
8+
139

1410
def getMyID(self,gist_name):
1511
'''
16-
Getting gistID of a gist in order to make the workflow
12+
Getting gistID of a gist in order to make the workflow
1713
easy and uninterrupted.
1814
'''
1915
r = requests.get(
@@ -60,7 +56,7 @@ def listall(self, **args):
6056
if (r.status_code == 200 ):
6157
for g,no in zip(r_text, range(0,limit)):
6258
allcomments.append(r.json()[no]['body'])
63-
59+
6460
return allcomments
6561

6662
raise Exception('Gistname not found')
@@ -86,7 +82,7 @@ def create(self, **args):
8682
raise Exception('Either provide authenticated user\'s Unambigious Gistname or any unique Gistid')
8783

8884
if self.gist_id:
89-
85+
9086
r = requests.post(
9187
'%s'%BASE_URL+'/gists/%s/comments' % self.gist_id,
9288
headers=self.gist.header,
@@ -100,13 +96,13 @@ def create(self, **args):
10096
'created_at': r.json()['created_at']
10197
}
10298
return response
103-
99+
104100

105101
raise Exception('Comment not created')
106102

107103

108104
def delete(self, **args):
109-
105+
110106
self.user = self.gist.username
111107

112108
self.gist_name = ''
@@ -145,7 +141,7 @@ def delete(self, **args):
145141

146142

147143
def get(self, **args):
148-
144+
149145
self.user = self.gist.username
150146

151147
self.gist_name = ''
@@ -180,7 +176,7 @@ def get(self, **args):
180176
'comment' : 'not exists'
181177
}
182178
return response
183-
179+
184180

185181
raise Exception('Comment not exits/deleted')
186182

@@ -210,7 +206,7 @@ def edit(self, **args):
210206
raise Exception('Either provide authenticated user\'s Unambigious Gistname or any unique Gistid')
211207

212208
if self.gist_id:
213-
209+
214210
r = requests.patch(
215211
'%s/gists/%s/comments/%s'%(BASE_URL,self.gist_id, self.commentid),
216212
headers=self.gist.header,
@@ -228,6 +224,6 @@ def edit(self, **args):
228224
response = {
229225
'comment' : 'not edited'
230226
}
231-
227+
232228

233229
raise Exception('Comment not edited')

simplegist/config.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
''' Either configure here or use command line arguments
1+
'''
2+
Either configure here or use command line arguments
23
-U/--username for username eg. -U 'softvar' or --username 'softvar'
34
_p/--password for password eg. -P 'secret_password' or --password 'secret_password'
4-
55
'''
66
# Your Github username
77
USERNAME = ''
@@ -12,3 +12,6 @@
1212
# or use -L/--limit as command-line arguments
1313
# Github API will always return <= 30 recent gists.
1414
LIMIT = None
15+
16+
BASE_URL = 'https://api.github.com'
17+
GIST_URL = 'https://gist.github.com'

simplegist/do.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
BASE_URL = 'https://api.github.com'
2-
GIST_URL = 'https://gist.github.com'
3-
41
import json
52
import requests
6-
7-
3+
from config import BASE_URL, GIST_URL
84

95
class Do:
106
def __init__(self, gist):
117
self.gist = gist
128

139
def getMyID(self,gist_name):
1410
'''
15-
Getting gistID of a gist in order to make the workflow
11+
Getting gistID of a gist in order to make the workflow
1612
easy and uninterrupted.
1713
'''
1814
r = requests.get(

simplegist/mygist.py

+19-21
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import json
22
import requests
3-
4-
BASE_URL = 'https://api.github.com'
5-
Link_URL = 'https://gist.github.com'
3+
from config import BASE_URL, GIST_URL
64

75
class Mygist:
86
def __init__(self, gist, **args):
@@ -11,12 +9,12 @@ def __init__(self, gist, **args):
119
self.user = args['user']
1210
else:
1311
self.user = self.gist.username
14-
12+
1513
def listall(self):
1614
'''
1715
will display all the filenames.
1816
Result can be stored in an array for easy fetching of gistNames
19-
for future purposes.
17+
for future purposes.
2018
eg. a = Gist().mygists().listall()
2119
print a[0] #to fetch first gistName
2220
'''
@@ -37,9 +35,9 @@ def listall(self):
3735

3836
def list(self, offset):
3937
'''
40-
will display only the required no. of filenames but in order.
38+
will display only the required no. of filenames but in order.
4139
Result can be stored in an array for easy fetching of gistNames
42-
for future purposes.
40+
for future purposes.
4341
eg. a = Gist().mygists().listall()
4442
print a[0] #to fetch first gistName
4543
'''
@@ -56,11 +54,11 @@ def list(self, offset):
5654
for key,value in r.json()[no]['files'].iteritems():
5755
file_name.append(value['filename'])
5856
return file_name
59-
raise Exception('Username not found')
57+
raise Exception('Username not found')
6058

6159
def getMyID(self,gist_name):
6260
'''
63-
Getting gistID of a gist in order to make the workflow
61+
Getting gistID of a gist in order to make the workflow
6462
easy and uninterrupted.
6563
'''
6664
r = requests.get(
@@ -82,7 +80,7 @@ def content(self, **args):
8280
Doesn't require manual fetching of gistID of a gist
8381
passing gistName will return the content of gist. In case,
8482
names are ambigious, provide GistID or it will return the contents
85-
of recent ambigious gistname
83+
of recent ambigious gistname
8684
'''
8785
self.gist_name = ''
8886
if 'name' in args:
@@ -93,7 +91,7 @@ def content(self, **args):
9391
else:
9492
raise Exception('Either provide authenticated user\'s Unambigious Gistname or any unique Gistid')
9593

96-
94+
9795
if self.gist_id:
9896
r = requests.get(
9997
'%s'%BASE_URL+'/gists/%s' %self.gist_id,
@@ -123,7 +121,7 @@ def getgist(self, **args):
123121
headers=self.gist.header,
124122
)
125123
if (r.status_code == 200):
126-
124+
127125
for key,value in r.json()['files'].iteritems():
128126
content = value['filename']
129127
return content
@@ -177,7 +175,7 @@ def edit(self, **args):
177175
}
178176
}
179177

180-
178+
181179
if self.gist_id:
182180
r = requests.patch(
183181
'%s/gists/%s'%(BASE_URL,self.gist_id),
@@ -191,7 +189,7 @@ def edit(self, **args):
191189
'created_at': r.json()['created_at'],
192190
'comments':r.json()['comments']
193191
}
194-
192+
195193
return response
196194

197195
raise Exception('No such gist found')
@@ -201,15 +199,15 @@ def delete(self, **args):
201199
'''
202200
Delete a gist by gistname/gistID
203201
'''
204-
202+
205203
if 'name' in args:
206204
self.gist_name = args['name']
207205
self.gist_id = self.getMyID(self.gist_name)
208206
elif 'id' in args:
209207
self.gist_id = args['id']
210208
else:
211209
raise Exception('Provide GistName to delete')
212-
210+
213211
url = 'gists'
214212
if self.gist_id:
215213
r = requests.delete(
@@ -228,7 +226,7 @@ def delete(self, **args):
228226
def starred(self, **args):
229227
'''
230228
List the authenticated user's starred gists
231-
'''
229+
'''
232230
ids =[]
233231
r = requests.get(
234232
'%s/gists/starred'%BASE_URL,
@@ -264,13 +262,13 @@ def links(self,**args):
264262
headers=self.gist.header,
265263
)
266264
if (r.status_code == 200):
267-
265+
268266
content = {
269267
'Github-User': r.json()['user']['login'],
270268
'GistID': r.json()['id'],
271-
'Gist-Link': '%s/%s/%s' %(Link_URL,self.gist.username,r.json()['id']),
272-
'Clone-Link': '%s/%s.git' %(Link_URL,r.json()['id']),
273-
'Embed-Script': '<script src="%s/%s/%s.js"</script>' %(Link_URL,self.gist.username,r.json()['id'])
269+
'Gist-Link': '%s/%s/%s' %(GIST_URL,self.gist.username,r.json()['id']),
270+
'Clone-Link': '%s/%s.git' %(GIST_URL,r.json()['id']),
271+
'Embed-Script': '<script src="%s/%s/%s.js"</script>' %(GIST_URL,self.gist.username,r.json()['id'])
274272
}
275273
return content
276274

simplegist/simplegist.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
import requests
22
import json
33

4-
from config import USERNAME, API_TOKEN
4+
from config import USERNAME, API_TOKEN, BASE_URL, GIST_URL
55

66
from mygist import Mygist
77
from do import Do
88
from comments import Comments
99

10-
BASE_URL = 'https://api.github.com'
11-
Link_URL = 'https://gist.github.com'
12-
1310
class Simplegist:
1411
"""
1512
Gist Base Class
@@ -38,7 +35,7 @@ def __init__(self, **args):
3835
else:
3936
self.api_token = API_TOKEN
4037

41-
38+
4239
# Set header information in every request.
4340
self.header = { 'X-Github-Username': self.username,
4441
'Content-Type': 'application/json',
@@ -90,15 +87,15 @@ def create(self, **args):
9087
}
9188

9289
r = requests.post(
93-
'%s%s' % (BASE_URL, url),
90+
'%s%s' % (BASE_URL, url),
9491
data=json.dumps(data),
9592
headers=self.header
9693
)
97-
if (r.status_code == 201):
94+
if (r.status_code == 201):
9895
response = {
99-
'Gist-Link': '%s/%s/%s' %(Link_URL,self.username,r.json()['id']),
100-
'Clone-Link': '%s/%s.git' %(Link_URL,r.json()['id']),
101-
'Embed-Script': '<script src="%s/%s/%s.js"</script>' %(Link_URL,self.username,r.json()['id']),
96+
'Gist-Link': '%s/%s/%s' %(GIST_URL,self.username,r.json()['id']),
97+
'Clone-Link': '%s/%s.git' %(GIST_URL,r.json()['id']),
98+
'Embed-Script': '<script src="%s/%s/%s.js"</script>' %(GIST_URL,self.username,r.json()['id']),
10299
'id': r.json()['id'],
103100
'created_at': r.json()['created_at'],
104101

0 commit comments

Comments
 (0)