Skip to content

Commit

Permalink
minor code tuning using inheritance so as to write less code
Browse files Browse the repository at this point in the history
  • Loading branch information
chfw committed Jan 16, 2017
1 parent d5645d9 commit f7560c7
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions pyexcel/sources/pydata.py
Expand Up @@ -28,7 +28,18 @@ def getvalue(self):
return self.__value


class RecordsReader(SheetReader):
class ArrayReader(SheetReader):

def row_iterator(self):
for row in self._native_sheet:
yield row

def column_iterator(self, row):
for cell in row:
yield cell


class RecordsReader(ArrayReader):

def row_iterator(self):
headers = []
Expand All @@ -45,12 +56,8 @@ def row_iterator(self):
values.append(row[k])
yield values

def column_iterator(self, row):
for cell in row:
yield cell


class DictReader(SheetReader):
class DictReader(ArrayReader):

def row_iterator(self):
keys = self._native_sheet.keys()
Expand All @@ -65,21 +72,6 @@ def row_iterator(self):
fillvalue=constants.DEFAULT_NA):
yield row

def column_iterator(self, row):
for cell in row:
yield cell


class ArrayReader(SheetReader):

def row_iterator(self):
for row in self._native_sheet:
yield row

def column_iterator(self, row):
for cell in row:
yield cell


class RecordsSource(Source):
"""
Expand Down

0 comments on commit f7560c7

Please sign in to comment.