Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions simplegist/comments.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
import requests
from config import BASE_URL, GIST_URL
from .config import BASE_URL, GIST_URL

class Comments:
def __init__(self, gist):
Expand Down Expand Up @@ -226,4 +226,4 @@ def edit(self, **args):
}


raise Exception('Comment not edited')
raise Exception('Comment not edited')
4 changes: 2 additions & 2 deletions simplegist/do.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
import requests
from config import BASE_URL, GIST_URL
from .config import BASE_URL, GIST_URL

class Do:
def __init__(self, gist):
Expand Down Expand Up @@ -127,4 +127,4 @@ def checkifstar(self, **args):
'starred': 'False'
}

return response
return response
4 changes: 2 additions & 2 deletions simplegist/mygist.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
import requests
from config import BASE_URL, GIST_URL
from .config import BASE_URL, GIST_URL

class Mygist:
def __init__(self, gist, **args):
Expand Down Expand Up @@ -272,4 +272,4 @@ def links(self,**args):
}
return content

raise Exception('No such gist found')
raise Exception('No such gist found')
26 changes: 10 additions & 16 deletions simplegist/simplegist.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import requests
import json

from config import USERNAME, API_TOKEN, BASE_URL, GIST_URL
from .config import USERNAME, API_TOKEN, BASE_URL, GIST_URL

from mygist import Mygist
from do import Do
from comments import Comments
from .mygist import Mygist
from .do import Do
from .comments import Comments

class Simplegist:
"""
Expand Down Expand Up @@ -78,7 +78,7 @@ def create(self, **args):
url = '/gists'

data = {"description": self.description,
"public": self.public,
"public": bool(self.public),
"files": {
self.gist_name: {
"content": self.content
Expand All @@ -89,17 +89,11 @@ def create(self, **args):
r = requests.post(
'%s%s' % (BASE_URL, url),
data=json.dumps(data),
headers=self.header
)
headers=self.header)

if (r.status_code == 201):
response = {
'Gist-Link': '%s/%s/%s' %(GIST_URL,self.username,r.json()['id']),
'Clone-Link': '%s/%s.git' %(GIST_URL,r.json()['id']),
'Embed-Script': '<script src="%s/%s/%s.js"</script>' %(GIST_URL,self.username,r.json()['id']),
'id': r.json()['id'],
'created_at': r.json()['created_at'],

}
response = r.json()
# response['url'] is a page which provides the json output in
# a web browser. Use it to see all possible keys
return response
raise Exception('Gist not created: server response was [%s] %s' % (r.status_code, r.text))