From 7224bda0478ba04be9cab035b05016071c700947 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Wed, 25 Dec 2013 16:48:40 -0500 Subject: [PATCH] Removed getitem_from_path---now uses eval() [eg, __getitem__] for such functions --- gramps/gen/merge/diff.py | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/gramps/gen/merge/diff.py b/gramps/gen/merge/diff.py index ccacbf5c3..6a2f37d37 100644 --- a/gramps/gen/merge/diff.py +++ b/gramps/gen/merge/diff.py @@ -447,27 +447,29 @@ class Struct(object): """ Given a path to a struct part, return the part, or None. - >>> Struct(struct)["primary_name.surname_list.0.surname"] + >>> Struct(struct)["primary_name"] """ # For where eval: - if isinstance(path, int): - return Struct(self.struct[path], self.db) - # Work way down to last part: - return self.getitem_from_path(parse(path)) + return self.getitem(path) - def getitem_from_path(self, path): - """ - Given a path that is already parsed, return item. - """ - struct = self.struct - for p in range(len(path)): - part = path[p] - struct = self.getitem(part, struct) - if isinstance(struct, Struct): - return struct.getitem_from_path(path[p+1:]) - if struct is None: - return None - return struct + # if isinstance(path, int): + # return self.get_ref_struct(self.struct[path]) + # # Work way down to last part: + # return self.getitem_from_path(parse(path)) + + # def getitem_from_path(self, path): + # """ + # Given a path that is already parsed, return item. + # """ + # struct = self.struct + # for p in range(len(path)): + # part = path[p] + # struct = self.getitem(part, struct) + # if isinstance(struct, Struct): + # return struct.getitem_from_path(path[p+1:]) + # if struct is None: + # return None + # return struct def get_ref_struct(self, item): """