Skip to content

Commit

Permalink
Fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
ymyzk committed Oct 8, 2014
1 parent 7134041 commit 1272ee4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -52,3 +52,5 @@ coverage.xml
# Sphinx documentation
docs/_build/

.idea/
venv/
2 changes: 1 addition & 1 deletion gyazo/api.py
Expand Up @@ -93,4 +93,4 @@ def _parse_and_check(self, data):
message = data_dict.get('message', 'Error')
raise GyazoError(message)

return (headers, data_dict,)
return (headers, data_dict,)
2 changes: 1 addition & 1 deletion gyazo/error.py
Expand Up @@ -5,4 +5,4 @@


class GyazoError(Exception):
pass
pass
36 changes: 15 additions & 21 deletions gyazo/image.py
Expand Up @@ -7,20 +7,18 @@
import dateutil.parser
import requests

from gyazo.error import GyazoError


class Image(object):
def __init__(self, **kwargs):
defaults = {
'created_at': None,
'image_id': None,
'permalink_url': None,
'star': None,
'thumb_url': None,
'type': None,
'url': None
}
for key in defaults:
setattr(self, key, kwargs.get(key, defaults[key]))
self.created_at = kwargs.get('created_at', None)
self.image_id = kwargs.get('image_id', None)
self.permalink_url = kwargs.get('permalink_url', None)
self.star = kwargs.get('star', None)
self.thumb_url = kwargs.get('thumb_url', None)
self.type = kwargs.get('type', None)
self.url = kwargs.get('url', None)

@property
def filename(self):
Expand Down Expand Up @@ -94,15 +92,11 @@ def from_dict(data):

class ImageList(object):
def __init__(self, **kwargs):
defaults = {
'total_count': None,
'current_page': None,
'per_page': None,
'user_type': None,
'images': []
}
for key in defaults:
setattr(self, key, kwargs.get(key, defaults[key]))
self.total_count = kwargs.get('total_count', None)
self.current_page = kwargs.get('current_page', None)
self.per_page = kwargs.get('per_page', None)
self.user_type = kwargs.get('user_type', None)
self.images = kwargs.get('images', [])

def __len__(self):
return len(self.images)
Expand Down Expand Up @@ -134,4 +128,4 @@ def set_from_headers(self, headers):

@staticmethod
def from_list(data):
return ImageList(images=[Image.from_dict(d) for d in data])
return ImageList(images=[Image.from_dict(d) for d in data])

0 comments on commit 1272ee4

Please sign in to comment.