Skip to content
Browse files

Fix: replaced field_names with fields.names()

  • Loading branch information...
1 parent 8604419 commit d8f542003e63c7fc0ceaed0ab769f8042197d35e Stefan Urbanek committed May 10, 2012
View
8 brewery/ds/elasticsearch_streams.py
@@ -95,14 +95,14 @@ def probe_record(record, parent=None):
fields.append(field)
- self._fields = list(fields)
- return self._fields
+ self.fields = list(fields)
+ return self.fields
def rows(self):
if not self.connection:
raise RuntimeError("Stream is not initialized")
from pyes.query import MatchAllQuery
- fields = self.field_names
+ fields = self.fields.names()
results = self.connection.search(MatchAllQuery(), search_type="scan", timeout="5m", size="200")
return ESRowIterator(results, fields)
@@ -232,7 +232,7 @@ def initialize(self):
def append(self, obj):
record = obj
if not isinstance(obj, dict):
- record = dict(zip(self.field_names, obj))
+ record = dict(zip(self.fields.names(), obj))
if self.expand:
record = expand_record(record)
View
4 brewery/ds/gdocs_streams.py
@@ -83,13 +83,13 @@ def rows(self):
if not self.worksheet:
raise RuntimeError("Stream is not initialized (no worksheet)")
iterator = self.worksheet.FindRecords(self.query_string).__iter__()
- return GDocRowIterator(self.field_names, iterator)
+ return GDocRowIterator(self.fields.names(), iterator)
def records(self):
if not self.worksheet:
raise RuntimeError("Stream is not initialized (no worksheet)")
iterator = self.worksheet.FindRecords(self.query_string).__iter__()
- return GDocRecordIterator(self.field_names, iterator)
+ return GDocRecordIterator(self.fields.names(), iterator)
class GDocRowIterator(object):
"""
View
2 brewery/ds/html_target.py
@@ -80,7 +80,7 @@ def initialize(self):
def append(self, obj):
if type(obj) == dict:
row = []
- for field in self.field_names:
+ for field in self.fields.names():
row.append(obj.get(field))
else:
row = obj
View
2 brewery/ds/xls_streams.py
@@ -70,7 +70,7 @@ def rows(self):
return XLSRowIterator(self.workbook, self.sheet, self.skip_rows)
def records(self):
- fields = self.field_names
+ fields = self.fields.names()
for row in self.rows():
yield dict(zip(fields, row))
View
12 brewery/ds/yaml_dir_streams.py
@@ -67,13 +67,13 @@ def records(self):
yield record
def rows(self):
- if not self.field_names:
- raise Exception("Field names not initialized, can not generate rows")
+ if not self.fields:
+ raise Exception("Fields are not initialized, can not generate rows")
+
+ field_names = self.fields.names()
for record in self.records():
- row = []
- for field in self.field_names:
- row.append(record.get(field))
+ row = [record.get(field) for field in field_names]
yield row
@@ -124,7 +124,7 @@ def append(self, obj):
if type(obj) == dict:
record = obj
else:
- record = dict(zip(self.field_names, obj))
+ record = dict(zip(self.fields.names(), obj))
base_name = self.template.substitute(__index=self.index, **record)
path = os.path.join(self.path, base_name)

0 comments on commit d8f5420

Please sign in to comment.
Something went wrong with that request. Please try again.