summaryrefslogtreecommitdiff
path: root/chimere/utils.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2016-01-13 19:52:52 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2016-01-13 19:52:52 +0100
commitf2c13e17e2dd43f8ab14c24e0d38dd532da40630 (patch)
tree558f581f8a9a5808cee1f825bc96b8046b1023a1 /chimere/utils.py
parent93afd55acf386270dade43103e32726400d3bd47 (diff)
downloadChimère-f2c13e17e2dd43f8ab14c24e0d38dd532da40630.tar.bz2
Chimère-f2c13e17e2dd43f8ab14c24e0d38dd532da40630.zip
Import JSON: allow prefixes and suffixes
Diffstat (limited to 'chimere/utils.py')
-rw-r--r--chimere/utils.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/chimere/utils.py b/chimere/utils.py
index 275f107..96c41b4 100644
--- a/chimere/utils.py
+++ b/chimere/utils.py
@@ -718,6 +718,8 @@ class JsonManager(ImportManager):
for item in values:
dct = default_dct.copy()
for k in filtr:
+ if k.startswith('prefix_') or k.startswith('suffix_'):
+ continue
if k in item and item[k]:
if filtr[k] not in dct:
dct[filtr[k]] = ""
@@ -740,6 +742,15 @@ class JsonManager(ImportManager):
item['y'])
if not dct['point']:
continue
+ for k in filtr:
+ if k.startswith('prefix_') or k.startswith('suffix_'):
+ pos = k.split('_')[0]
+ key = '_'.join(k.split('_')[1:])
+ if key in dct:
+ if pos == 'prefix':
+ dct[key] = filtr[k] + dct[key]
+ else:
+ dct[key] += filtr[k]
cls = Marker
pl_id = (dct.pop('id') if 'id' in dct else dct['name']) \
+ "-" + unicode(self.importer_instance.pk)