Skip to content

Commit

Permalink
Remove lambdas
Browse files Browse the repository at this point in the history
  • Loading branch information
geographika committed Jan 17, 2018
1 parent 398141a commit ca93dd7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion mappyfile/pprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,17 @@ def format_pair_list(self, key, pair_list, level):

return lines


def format_repeated_pair_list(self, key, root_list, level):
"""
Process (possibly) repeated lists of pairs e.g. POINTs blocks
"""

lines = []
depth = lambda L: isinstance(L, (tuple, list)) and max(map(depth, L)) + 1

def depth(L):
return isinstance(L, (tuple, list)) and max(map(depth, L)) + 1

if depth(root_list) == 2:
# single set of points only
root_list = [root_list]
Expand Down
5 changes: 4 additions & 1 deletion mappyfile/transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ def composite(self, t):
# if points are already in a feature then
# allow for multipart features in a nested list
existing_points = composite_dict[key_name]
depth = lambda L: isinstance(L, (tuple, list)) and max(map(depth, L)) + 1

def depth(L):
return isinstance(L, (tuple, list)) and max(map(depth, L)) + 1

if depth(existing_points) == 2:
composite_dict[key_name] = [existing_points]
composite_dict[key_name].append(d[key_name])
Expand Down

0 comments on commit ca93dd7

Please sign in to comment.