# Path: flattentool/input.py
# def path_search(
#     nested_dict, path_list, id_fields=None, path=None, top=False, top_sheet=False
# ):
#     if not path_list:
#         return nested_dict
# 
#     id_fields = id_fields or {}
#     parent_field = path_list[0]
#     path = parent_field if path is None else path + "/" + parent_field
# 
#     if parent_field.endswith("[]") or top:
#         if parent_field.endswith("[]"):
#             parent_field = parent_field[:-2]
#         if parent_field not in nested_dict:
#             nested_dict[parent_field] = TemporaryDict(
#                 keyfield=id_name, top_sheet=top_sheet, xml=xml  # noqa
#             )
#         sub_sheet_id = id_fields.get(path + "/id")
#         if sub_sheet_id not in nested_dict[parent_field]:
#             nested_dict[parent_field][sub_sheet_id] = {}
#         return path_search(
#             nested_dict[parent_field][sub_sheet_id],
#             path_list[1:],
#             id_fields=id_fields,
#             path=path,
#             top_sheet=top_sheet,
#         )
#     else:
#         if parent_field not in nested_dict:
#             nested_dict[parent_field] = OrderedDict()
#         return path_search(
#             nested_dict[parent_field],
#             path_list[1:],
#             id_fields=id_fields,
#             path=path,
#             top_sheet=top_sheet,
#         )


from flattentool.input import path_search
# -*- coding: utf-8 -*-
"""
Tests of functions in input.py
Tests of SpreadsheetInput class and its children are in test_input_SpreadsheetInput*.py
"""
from __future__ import unicode_literals



def test_path_search():
    goal_dict = {}
    assert goal_dict is not {}  # following tests rely on this

# Path: flattentool/input.py
# def path_search(
#     nested_dict, path_list, id_fields=None, path=None, top=False, top_sheet=False
# ):
#     if not path_list:
#         return nested_dict
# 
#     id_fields = id_fields or {}
#     parent_field = path_list[0]
#     path = parent_field if path is None else path + "/" + parent_field
# 
#     if parent_field.endswith("[]") or top:
#         if parent_field.endswith("[]"):
#             parent_field = parent_field[:-2]
#         if parent_field not in nested_dict:
#             nested_dict[parent_field] = TemporaryDict(
#                 keyfield=id_name, top_sheet=top_sheet, xml=xml  # noqa
#             )
#         sub_sheet_id = id_fields.get(path + "/id")
#         if sub_sheet_id not in nested_dict[parent_field]:
#             nested_dict[parent_field][sub_sheet_id] = {}
#         return path_search(
#             nested_dict[parent_field][sub_sheet_id],
#             path_list[1:],
#             id_fields=id_fields,
#             path=path,
#             top_sheet=top_sheet,
#         )
#     else:
#         if parent_field not in nested_dict:
#             nested_dict[parent_field] = OrderedDict()
#         return path_search(
#             nested_dict[parent_field],
#             path_list[1:],
#             id_fields=id_fields,
#             path=path,
#             top_sheet=top_sheet,
#         )


# Path: flattentool/tests/test_input.py
from flattentool.input import path_search

# -*- coding: utf-8 -*-
"""
Tests of functions in input.py
Tests of SpreadsheetInput class and its children are in test_input_SpreadsheetInput*.py
"""
from __future__ import unicode_literals



def test_path_search():
    goal_dict = {}
    assert goal_dict is not {}  # following tests rely on this

    assert path_search(goal_dict, []) is goal_dict