def createGeorge(self, birthPlace, deathPlace): """ :param PlaceDescription birthPlace: birth place :param PlaceDescription deathPlace: death place :return: """ person = Person() person.gender.type = GenderType.Male #person.setGender(GenderType.Male) fact = Fact() fact.id = u"123" fact.type = FactType.Birth fact.date.original = u"February 22, 1732" fact.date.formal = u"+1732-02-22" fact.place.original = birthPlace.names.get().value.lower() fact.place.description = u"#" + birthPlace.id person.addFact(fact) fact = Fact() fact.id = u"456" fact.type = FactType.Death fact.date.original = u"December 14, 1799" fact.date.formal = u"+1799-12-14T22:00:00" fact.place.original = deathPlace.names.get().value.lower() fact.place.description = u"#" + deathPlace.id person.addFact(fact) name = Name() nameForm = NameForm() nameForm.fullText = u"George Washington" part = NamePart() part.type = NamePartType.Given part.value = u"George" nameForm.parts.append(part) part = NamePart() part.type = NamePartType.Surname part.value = u"Washington" nameForm.parts.append(part) name.nameForms.append(nameForm) name.id = u"789" person.names.append(name) person.id = u"BBB-BBBB" return person
def createMartha(self, birthPlace, deathPlace): """ :param PlaceDescription birthPlace: birth place :param PlaceDescription deathPlace: death place :return: """ person = Person() person.gender.type = GenderType.Male #person.setGender(GenderType.Male) fact = Fact() fact.id = u"321" fact.type = FactType.Birth fact.date.original = u"June 2, 1731" fact.date.formal = u"+1731-06-02" fact.place.original = birthPlace.names.get().value.lower() fact.place.description = u"#" + birthPlace.id person.addFact(fact) fact = Fact() fact.id = u"654" fact.type = FactType.Death fact.date.original = u"May 22, 1802" fact.date.formal = u"+1802-05-22" fact.place.original = deathPlace.names.get().value.lower() fact.place.description = u"#" + deathPlace.id person.addFact(fact) name = Name() nameForm = NameForm() nameForm.fullText = u"Martha Dandridge Custis" part = NamePart() part.type = NamePartType.Given part.value = u"Martha Dandridge" nameForm.parts.append(part) part = NamePart() part.type = NamePartType.Surname part.value = u"Custis" nameForm.parts.append(part) name.nameForms.append(nameForm) name.id = u"987" person.names.append(name) person.id = u"CCC-CCCC" return person
def testExample(self): import os contributor = Agent( {'id': u"A-1",}) contributor.name(u"Jane Doe") contributor.email( u"*****@*****.**" ) repository = Agent({'id': u"A-2"}) repository.name(u"General Registry Office, Southport") attribution = Attribution() attribution.contributor.resource = u"#" + contributor.id attribution.modified = self.parse("2014-03-07") sourceDescription = SourceDescription() sourceDescription.id = u"S-1" sourceDescription.titles.append( u"Birth Certificate of Emma Bocock, 23 July 1843, General Registry Office" ) sourceDescription.resourceType = ResourceType.PhysicalArtifact citation = SourceCitation({'value': u'England, birth certificate for Emma Bocock, born 23 July 1843; citing 1843 Birth in District and Sub-district of Ecclesall-Bierlow in the County of York, 303; General Registry Office, Southport.'}) sourceDescription.citations.append(citation) sourceDescription.created = self.parse("1843-07-27") sourceDescription.repository.resource = "#" + repository.id birth = Fact() birth.type = FactType.Birth birth.date.original = u"23 June 1843" birth.place.original = u"Broadfield Bar, Abbeydale Road, Ecclesall-Bierlow, York, England, United Kingdom" emma = Person() emma.id = u"P-1" emma.extracted = True emma.sources.append(sourceDescription) emma.setName(u"Emma Bocock") emma.setGender(GenderType.Female) emma.addFact(birth) occupation = Fact({'type': FactType.Occupation, 'value': u"Toll Collector"}) father = Person({'id': u'P-2'}) father.extracted = True father.sources.append(sourceDescription) father.setName(u"William Bocock") father.addFact(occupation) mother = Person({'id': u'P-3'}) mother.extracted = True mother.sources.append(sourceDescription) mother.setName(u'Sarah Bocock formerly Brough') fatherRelationship = Relationship() fatherRelationship.type = RelationshipType.ParentChild fatherRelationship.setPerson1(father) fatherRelationship.setPerson2(emma) motherRelationship = Relationship() motherRelationship.type = RelationshipType.ParentChild motherRelationship.setPerson1(mother) motherRelationship.setPerson2(emma) analysis = Document({'id' : u'D-1', 'text': u"...Jane Doe's analysis document..."}) emmaConclusion = Person({'id': u'C-1'}) emmaReference = EvidenceReference() emmaReference.setReference(emma) emmaConclusion.evidence.append(EvidenceReference(emma)) emmaConclusion.analysis = ResourceReference(analysis) gx = Gedcomx() gx.agents.append(contributor) gx.agents.append(repository) gx.attribution = attribution gx.sourceDescriptions.append(sourceDescription) gx.persons.extend([emma, father, mother]) gx.relationships.extend([fatherRelationship, motherRelationship]) gx.documents.append(analysis) gx.persons.append(emmaConclusion) gx_dict = gx.to_dict() # Read the json output from java program and initialize a gedcomx object. dirname = os.path.abspath(os.path.dirname(__file__)) java_gx = Gedcomx() java_gx.load( open(os.path.join(dirname, 'data', 'EmmaBocockExample_java.json') )) java_dict = java_gx.to_dict() # Compare both objects. self.assertDictEqual(gx_dict, java_dict) self.assertDictEqual(java_dict, gx_dict)
def testExample(self): import os contributor = Agent({ 'id': u"A-1", }) contributor.name(u"Jane Doe") contributor.email(u"*****@*****.**") repository = Agent({'id': u"A-2"}) repository.name(u"General Registry Office, Southport") attribution = Attribution() attribution.contributor.resource = u"#" + contributor.id attribution.modified = self.parse("2014-03-07") sourceDescription = SourceDescription() sourceDescription.id = u"S-1" sourceDescription.titles.append( u"Birth Certificate of Emma Bocock, 23 July 1843, General Registry Office" ) sourceDescription.resourceType = ResourceType.PhysicalArtifact citation = SourceCitation({ 'value': u'England, birth certificate for Emma Bocock, born 23 July 1843; citing 1843 Birth in District and Sub-district of Ecclesall-Bierlow in the County of York, 303; General Registry Office, Southport.' }) sourceDescription.citations.append(citation) sourceDescription.created = self.parse("1843-07-27") sourceDescription.repository.resource = "#" + repository.id birth = Fact() birth.type = FactType.Birth birth.date.original = u"23 June 1843" birth.place.original = u"Broadfield Bar, Abbeydale Road, Ecclesall-Bierlow, York, England, United Kingdom" emma = Person() emma.id = u"P-1" emma.extracted = True emma.sources.append(sourceDescription) emma.setName(u"Emma Bocock") emma.setGender(GenderType.Female) emma.addFact(birth) occupation = Fact({ 'type': FactType.Occupation, 'value': u"Toll Collector" }) father = Person({'id': u'P-2'}) father.extracted = True father.sources.append(sourceDescription) father.setName(u"William Bocock") father.addFact(occupation) mother = Person({'id': u'P-3'}) mother.extracted = True mother.sources.append(sourceDescription) mother.setName(u'Sarah Bocock formerly Brough') fatherRelationship = Relationship() fatherRelationship.type = RelationshipType.ParentChild fatherRelationship.setPerson1(father) fatherRelationship.setPerson2(emma) motherRelationship = Relationship() motherRelationship.type = RelationshipType.ParentChild motherRelationship.setPerson1(mother) motherRelationship.setPerson2(emma) analysis = Document({ 'id': u'D-1', 'text': u"...Jane Doe's analysis document..." }) emmaConclusion = Person({'id': u'C-1'}) emmaReference = EvidenceReference() emmaReference.setReference(emma) emmaConclusion.evidence.append(EvidenceReference(emma)) emmaConclusion.analysis = ResourceReference(analysis) gx = Gedcomx() gx.agents.append(contributor) gx.agents.append(repository) gx.attribution = attribution gx.sourceDescriptions.append(sourceDescription) gx.persons.extend([emma, father, mother]) gx.relationships.extend([fatherRelationship, motherRelationship]) gx.documents.append(analysis) gx.persons.append(emmaConclusion) gx_dict = gx.to_dict() # Read the json output from java program and initialize a gedcomx object. dirname = os.path.abspath(os.path.dirname(__file__)) java_gx = Gedcomx() java_gx.load( open(os.path.join(dirname, 'data', 'EmmaBocockExample_java.json'))) java_dict = java_gx.to_dict() # Compare both objects. self.assertDictEqual(gx_dict, java_dict) self.assertDictEqual(java_dict, gx_dict)