__find_next_gramps_id question

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

__find_next_gramps_id question

prculley
While looking into an issue where multiple GEDCOM imports created duplicate gramps_ids, I found that the set searched contained an bunch of bytes strings (bytes: b'E0001') and the search item was a 'str' (str: E0001).  So of course a match was not found.  Probably another Python2.x to 3.x issue.

I also realized that the libgedcom.py module has its own version of find_next gramps Id.  And that there are two other versions defined in our code.

The one in db.dictionary.py is similar to the libgedcom;
    def __find_next_gramps_id(self, prefix, map_index, trans):
        """
        Helper function for find_next_<object>_gramps_id methods
        """
        index = prefix % map_index
        while trans.get(str(index), txn=self.txn) is not None:
            map_index += 1
            index = prefix % map_index
        map_index += 1
        return (map_index, index)
 
but the one in db.read.py is different.  It appears to be properly converting the search term to bytes before the search.
    def __find_next_gramps_id(self, prefix, map_index, trans):
        """
        Helper function for find_next_<object>_gramps_id methods
        """
        index = prefix % map_index
        #in bytes
        bindex = index.encode('utf-8')
        while trans.get(bindex, txn=self.txn) is not None:
            map_index += 1
            index = prefix % map_index
            bindex = index.encode('utf-8')
        map_index += 1
        return (map_index, index)


My question is why two versions in dict and read?  And should they be different?
I can fix libgedcom.py by using the "index.encode" trick to correct the immediate issue, but I wonder of a latent problem exists with the version in db.dict.py.

Paul Culley
 

------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel