Add dictization_functions unflatten patch
This commit is contained in:
parent
e438bb70f3
commit
16dc43e7fd
|
@ -0,0 +1,32 @@
|
|||
--- ckan/ckan/lib/navl/dictization_functions.py 2020-10-14 10:48:40.146291362 +0200
|
||||
+++ dictization_functions_unflatten_patch.py 2020-10-14 10:48:29.979771608 +0200
|
||||
@@ -440,19 +440,24 @@
|
||||
for flattend_key in sorted(data.keys(), key=flattened_order_key):
|
||||
current_pos = unflattened
|
||||
|
||||
+ if (len(flattend_key) > 1
|
||||
+ and not flattend_key[0] in convert_to_list
|
||||
+ and not flattend_key[0] in unflattened):
|
||||
+ convert_to_list.append(flattend_key[0])
|
||||
+
|
||||
for key in flattend_key[:-1]:
|
||||
try:
|
||||
current_pos = current_pos[key]
|
||||
- except IndexError:
|
||||
- new_pos = {}
|
||||
- current_pos.append(new_pos)
|
||||
- current_pos = new_pos
|
||||
except KeyError:
|
||||
- new_pos = []
|
||||
+ new_pos = {}
|
||||
current_pos[key] = new_pos
|
||||
current_pos = new_pos
|
||||
current_pos[flattend_key[-1]] = data[flattend_key]
|
||||
|
||||
+ for key in convert_to_list:
|
||||
+ unflattened[key] = [unflattened[key][s]
|
||||
+ for s in sorted(unflattened[key])]
|
||||
+
|
||||
return unflattened
|
||||
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
--- ckan/ckan/lib/navl/dictization_functions.py 2020-10-14 10:39:46.319132692 +0200
|
||||
+++ dictization_functions_unflatten_patch.py 2020-10-14 10:40:38.204657981 +0200
|
||||
@@ -442,19 +442,24 @@
|
||||
for flattend_key in sorted(data.keys(), key=flattened_order_key):
|
||||
current_pos = unflattened
|
||||
|
||||
+ if (len(flattend_key) > 1
|
||||
+ and not flattend_key[0] in convert_to_list
|
||||
+ and not flattend_key[0] in unflattened):
|
||||
+ convert_to_list.append(flattend_key[0])
|
||||
+
|
||||
for key in flattend_key[:-1]:
|
||||
try:
|
||||
current_pos = current_pos[key]
|
||||
- except IndexError:
|
||||
- new_pos = {}
|
||||
- current_pos.append(new_pos)
|
||||
- current_pos = new_pos
|
||||
except KeyError:
|
||||
- new_pos = []
|
||||
+ new_pos = {}
|
||||
current_pos[key] = new_pos
|
||||
current_pos = new_pos
|
||||
current_pos[flattend_key[-1]] = data[flattend_key]
|
||||
|
||||
+ for key in convert_to_list:
|
||||
+ unflattened[key] = [unflattened[key][s]
|
||||
+ for s in sorted(unflattened[key])]
|
||||
+
|
||||
return unflattened
|
||||
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
--- ckan/ckan/lib/navl/dictization_functions.py 2020-10-14 10:45:07.519582188 +0200
|
||||
+++ dictization_functions_unflatten_patch.py 2020-10-14 10:46:26.258305671 +0200
|
||||
@@ -410,19 +410,24 @@
|
||||
for flattend_key in sorted(data.keys(), key=flattened_order_key):
|
||||
current_pos = unflattened
|
||||
|
||||
+ if (len(flattend_key) > 1
|
||||
+ and not flattend_key[0] in convert_to_list
|
||||
+ and not flattend_key[0] in unflattened):
|
||||
+ convert_to_list.append(flattend_key[0])
|
||||
+
|
||||
for key in flattend_key[:-1]:
|
||||
try:
|
||||
current_pos = current_pos[key]
|
||||
- except IndexError:
|
||||
- new_pos = {}
|
||||
- current_pos.append(new_pos)
|
||||
- current_pos = new_pos
|
||||
except KeyError:
|
||||
- new_pos = []
|
||||
+ new_pos = {}
|
||||
current_pos[key] = new_pos
|
||||
current_pos = new_pos
|
||||
current_pos[flattend_key[-1]] = data[flattend_key]
|
||||
|
||||
+ for key in convert_to_list:
|
||||
+ unflattened[key] = [unflattened[key][s]
|
||||
+ for s in sorted(unflattened[key])]
|
||||
+
|
||||
return unflattened
|
||||
|
||||
|
Loading…
Reference in New Issue