Struct.from_struct is also a classmethod

This commit is contained in:
Doug Blank 2015-12-29 13:09:49 -05:00
parent 74f9fb1b8e
commit f4af5277e6

View File

@ -308,12 +308,16 @@ class Struct(object):
add_func = self.db._tables[name]["add_func"] add_func = self.db._tables[name]["add_func"]
add_func(new_obj, trans) add_func(new_obj, trans)
def from_struct(self): @classmethod
def from_struct(self, struct=None):
""" """
Given a struct with metadata, create a Gramps object. Given a struct with metadata, create a Gramps object.
self is class when called as a classmethod.
""" """
from gramps.gen.lib import (Person, Family, Event, Source, Place, Citation, from gramps.gen.lib import (Person, Family, Event, Source, Place, Citation,
Repository, MediaObject, Note, Tag, Date) Repository, MediaObject, Note, Tag, Date)
if struct is None:
struct = self.struct struct = self.struct
if isinstance(struct, dict): if isinstance(struct, dict):
if "_class" in struct.keys(): if "_class" in struct.keys():