Skip to content

Commit 49e685b

Browse files
committed
Fix Python 2 compatibility
1 parent 7f57801 commit 49e685b

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

flattentool/input.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,11 @@ def convert_dict_titles(self, dicts):
4242
(``dicts``) using the titles lookup in the schema parser.
4343
4444
"""
45-
# TODO add this to TitleLookup. Breaks the tests in test_unflatten
46-
# titles_map = {title.replace(' ', '').lower(): title for title in titles}
47-
if self.parser:
48-
for d in dicts:
45+
for d in dicts:
46+
if self.parser:
4947
yield { self.parser.title_lookup.lookup_header(k):v for k,v in d.items() }
50-
else:
51-
return dicts
48+
else:
49+
yield d
5250

5351
def __init__(self, input_name='', main_sheet_name='', timezone_name='UTC', root_id='ocid', convert_titles=False):
5452
self.input_name = input_name

flattentool/schema.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ def __getitem__(self, key):
4747
return self.data[key.replace(' ', '').lower()]
4848

4949
def __contains__(self, key):
50-
return key.replace(' ', '').lower() in self.data
50+
if key is None:
51+
return False
52+
else:
53+
return key.replace(' ', '').lower() in self.data
5154

5255

5356
class SchemaParser(object):

0 commit comments

Comments
 (0)