Skip to content

Commit

Permalink
Merge pull request #395 from OpenDataServices/update-black
Browse files Browse the repository at this point in the history
Update black, to avoid click import error
  • Loading branch information
Bjwebb authored Jun 16, 2022
2 parents 4c58e2f + 24308f7 commit 84d83cb
Show file tree
Hide file tree
Showing 14 changed files with 882 additions and 166 deletions.
2 changes: 1 addition & 1 deletion flattentool/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,7 @@ def to_list(self):


def temporarydicts_to_lists(nested_dict):
""" Recursively transforms TemporaryDicts to lists inplace. """
"""Recursively transforms TemporaryDicts to lists inplace."""
for key, value in nested_dict.items():
if isinstance(value, Cell):
continue
Expand Down
35 changes: 25 additions & 10 deletions flattentool/json_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ def dicts_to_list_of_dicts(lists_of_dicts_paths_set, xml_dict, path=()):

def list_dict_consistency(xml_dict):
"""
For use with XML files opened with xmltodict.
For use with XML files opened with xmltodict.
If there is only one tag, xmltodict produces a dict. If there are
multiple, xmltodict produces a list of dicts. This functions replaces
dicts with lists of dicts, if there exists a list of dicts for the same
path elsewhere in the file.
If there is only one tag, xmltodict produces a dict. If there are
multiple, xmltodict produces a list of dicts. This functions replaces
dicts with lists of dicts, if there exists a list of dicts for the same
path elsewhere in the file.
"""
lists_of_dicts_paths_set = set(lists_of_dicts_paths(xml_dict))
dicts_to_list_of_dicts(lists_of_dicts_paths_set, xml_dict)
Expand Down Expand Up @@ -214,7 +214,9 @@ def __init__(
if self.xml:
with codecs.open(json_filename, "rb") as xml_file:
top_dict = xmltodict.parse(
xml_file, force_list=(root_list_path,), force_cdata=True,
xml_file,
force_list=(root_list_path,),
force_cdata=True,
)
# AFAICT, this should be true for *all* XML files
assert len(top_dict) == 1
Expand Down Expand Up @@ -468,13 +470,19 @@ def parse_json_dict(
self.use_titles
and parent_name + key in self.rollup
and self.schema_parser.sub_sheet_titles.get(
(parent_name, key,)
(
parent_name,
key,
)
)
in self.schema_parser.sub_sheets
):
relevant_subsheet = self.schema_parser.sub_sheets.get(
self.schema_parser.sub_sheet_titles.get(
(parent_name, key,)
(
parent_name,
key,
)
)
)
if relevant_subsheet is not None:
Expand Down Expand Up @@ -546,10 +554,17 @@ def parse_json_dict(
if (
self.use_titles
and self.schema_parser
and (parent_name, key,) in self.schema_parser.sub_sheet_titles
and (
parent_name,
key,
)
in self.schema_parser.sub_sheet_titles
):
sub_sheet_name = self.schema_parser.sub_sheet_titles[
(parent_name, key,)
(
parent_name,
key,
)
]
else:
sub_sheet_name = make_sub_sheet_name(
Expand Down
2 changes: 1 addition & 1 deletion flattentool/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def open(self):
self.workbook = OpenDocumentSpreadsheet()

def _make_cell(self, value):
""" Util for creating an ods cell """
"""Util for creating an ods cell"""

if value:
try:
Expand Down
5 changes: 4 additions & 1 deletion flattentool/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,10 @@ def parse_schema_dict(
path_separator=":",
)
self.sub_sheet_titles[
(parent_path, property_name,)
(
parent_path,
property_name,
)
] = sub_sheet_name
else:
sub_sheet_name = make_sub_sheet_name(
Expand Down
Loading

0 comments on commit 84d83cb

Please sign in to comment.