@@ -160,13 +160,15 @@ def convert_json(config, **kwargs):
160
160
medias [handle ]['filepath' ] = Path (base_media + '/' + jl ['path' ])
161
161
162
162
persons_out = {}
163
+ persons_temp = {}
163
164
for handle in persons :
164
165
id = persons [handle ]['id' ]
165
-
166
166
persons_out [id ] = {}
167
-
168
167
persons_out [id ]['id' ] = id
169
168
169
+ persons_temp [handle ] = {}
170
+ persons_temp [handle ]['id' ] = id
171
+
170
172
persons_out [id ]['name' ] = persons [handle ]['firstname' ] + ' ' + persons [handle ]['surname' ]
171
173
persons_out [id ]['longname' ] = persons [handle ]['givenname' ] + ' ' + persons [handle ]['surname' ]
172
174
if persons [handle ]['title' ]:
@@ -199,11 +201,19 @@ def convert_json(config, **kwargs):
199
201
persons_out [id ]['deathplace' ] = '?' #make sure deathplace is set, so missing deathyear won't make someone immortal
200
202
if birthdate and deathdate :
201
203
persons_out [id ]['age' ] = relativedelta (deathdate , birthdate ).years
204
+
205
+ persons_temp [handle ]['birthdate' ] = birthdate
206
+ persons_temp [handle ]['deathdate' ] = deathdate
207
+
202
208
persons_out [id ]['own_unions' ] = []
203
209
for handle2 in families :
204
210
#person is the child of a family
205
211
if handle in families [handle2 ]['children' ]:
206
212
persons_out [id ]['parent_union' ] = families [handle2 ]['id' ]
213
+ if families [handle2 ]['father' ]:
214
+ persons_temp [handle ]['fhandle' ] = families [handle2 ]['father' ]
215
+ if families [handle2 ]['mother' ]:
216
+ persons_temp [handle ]['mhandle' ] = families [handle2 ]['mother' ]
207
217
208
218
#person has own families
209
219
if ((families [handle2 ]['father' ] and handle in families [handle2 ]['father' ]) or
@@ -254,7 +264,22 @@ def convert_json(config, **kwargs):
254
264
unions_out [id ]['children' ].append (persons [handle2 ]['id' ])
255
265
links_out .append ([id ,persons [handle2 ]['id' ]])
256
266
257
- #print('data = '+json.dumps({'start':'I0036','openup':['I0000', 'I0033'], 'persons':persons_out, 'unions':unions_out, 'links':links_out}, indent=4))
267
+ for handle in persons_temp :
268
+ id = persons_temp [handle ]['id' ]
269
+ birthdate = persons_temp [handle ]['birthdate' ]
270
+ if 'fhandle' in persons_temp [handle ]:
271
+ handle2 = persons_temp [handle ]['fhandle' ]
272
+ if handle2 in persons_temp :
273
+ parent_birthdate = persons_temp [handle2 ]['birthdate' ]
274
+ if birthdate and parent_birthdate :
275
+ persons_out [id ]['fageab' ] = relativedelta (birthdate , parent_birthdate ).years
276
+ if 'mhandle' in persons_temp [handle ]:
277
+ handle2 = persons_temp [handle ]['mhandle' ]
278
+ if handle2 in persons_temp :
279
+ parent_birthdate = persons_temp [handle2 ]['birthdate' ]
280
+ if birthdate and parent_birthdate :
281
+ persons_out [id ]['mageab' ] = relativedelta (birthdate , parent_birthdate ).years
282
+
258
283
jsoncontent = {}
259
284
jsoncontent ['start' ] = START
260
285
if OPENUP :
@@ -264,4 +289,4 @@ def convert_json(config, **kwargs):
264
289
jsoncontent ['links' ] = links_out
265
290
filecontent = 'data = ' + json .dumps (jsoncontent ) + ";"
266
291
with open (Path (cur_dir + '/' + filename_out ), 'w' ) as file :
267
- file .write (filecontent )
292
+ file .write (filecontent )
0 commit comments