Skip to content
This repository has been archived by the owner on May 20, 2021. It is now read-only.

Commit

Permalink
API return objects are now iterable (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vysybyl authored and Detrous committed Jan 14, 2020
1 parent c99a18d commit 9cb5c64
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions darksky/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ def __init__(self, summary=None, icon=None, data=None, timezone=None):

def __repr__(self):
return '%s([%d])' % (self.__class__.__name__, len(self.data))

def __iter__(self):
return iter(self.data)


class AutoInit:

def __init__(self, **params):
try:
timezone = pytz.timezone(params.pop('timezone', None))
Expand All @@ -42,5 +46,8 @@ def __init__(self, **params):
else:
setattr(self, field, None)

def __iter__(self):
return iter(self.__dict__.items())

def __repr__(self):
return '%s(%s)' % (self.__class__.__name__, getattr(self, 'time', ''))

0 comments on commit 9cb5c64

Please sign in to comment.