andy-z / ged4py

GEDCOM tools for Python
MIT License
18 stars 7 forks source link

Enhancement : dict of Record to support quick references #37

Open ukgenes opened 3 years ago

ukgenes commented 3 years ago

Description

Enhancement: produce a dict of Records to support single record reference and pointer decoding

Could also make some minor rework to final refresh to allow pointer references to resolve using this dict

Would like to add records thru a UI ... preferably would auto connect xref_id independent of which is added first i.e. source or target

What I Did

class Record pointer = {}

def make_record( ... ... if rec.xref_id != None: Record.pointer(rec.xref_id) = rec


can then reference any Record as Record.pointer[xref_id] ...

ukgenes commented 3 years ago

Andy ... thx for the other changes ... the code you didn't understand was my experimenting and is more properly

Record.pointer['@I293@'].subtag("CENS/DATE")

allowing direct access to both a record and any pointers that refer to it

....

The other idea would be to have a root Record that has the other records as sub_tags using a dict instead of a list? sounds a bit messy ...

andy-z commented 3 years ago

@ukgenes, I am not quite sure what do you want to achieve here. ged4py relies heavily on an assumption that all records come from a single GEDCOM file. "Adding" the records that are not from the same file or just were created by yourself is not supported, and it would require significant change in infrastructure to support it (but I have not heard of any request yet to support it). ged4py is not a generic editing tool for GEDCOM data, it's only a parser, For editing and saving data you probably need something more advanced.

If what you are doing works for you you can continue doing it, and you do not really need pointer dictionary to be a member of Record - it can be any global variable. Or if I am misunderstanding what you want please explain it with more specific examples.