├── GEDCOMToJSONConverter ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-34.pyc │ └── settings.cpython-34.pyc ├── settings.py ├── urls.py └── wsgi.py ├── README.md ├── converter ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-34.pyc │ ├── models.cpython-34.pyc │ └── tests.cpython-34.pyc ├── admin.py ├── business_logic │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-34.pyc │ │ └── gedcom_parser.cpython-34.pyc │ ├── exceptions │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-34.pyc │ │ │ └── invalid_file_exception.cpython-34.pyc │ │ └── invalid_file_exception.py │ └── gedcom_parser.py ├── migrations │ └── __init__.py ├── models.py ├── tests │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-34.pyc │ │ ├── model_tests.cpython-34.pyc │ │ ├── test_gedcom_parser.cpython-34.pyc │ │ ├── test_marriage.cpython-34.pyc │ │ ├── test_models.cpython-34.pyc │ │ ├── test_parent_relationship.cpython-34.pyc │ │ └── test_person.cpython-34.pyc │ ├── test_gedcom_parser.py │ ├── test_marriage.py │ ├── test_parent_relationship.py │ └── test_person.py └── views.py └── manage.py /GEDCOMToJSONConverter/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PatKayongo/GEDCOMToJSONConverter/ab9b8b1abc46f7e8c47bf8ab0d42bb80faf945c1/GEDCOMToJSONConverter/__init__.py -------------------------------------------------------------------------------- /GEDCOMToJSONConverter/__pycache__/__init__.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PatKayongo/GEDCOMToJSONConverter/ab9b8b1abc46f7e8c47bf8ab0d42bb80faf945c1/GEDCOMToJSONConverter/__pycache__/__init__.cpython-34.pyc -------------------------------------------------------------------------------- /GEDCOMToJSONConverter/__pycache__/settings.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PatKayongo/GEDCOMToJSONConverter/ab9b8b1abc46f7e8c47bf8ab0d42bb80faf945c1/GEDCOMToJSONConverter/__pycache__/settings.cpython-34.pyc -------------------------------------------------------------------------------- /GEDCOMToJSONConverter/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for GEDCOMToJSONConverter project. 3 | 4 | For more information on this file, see 5 | https://docs.djangoproject.com/en/1.7/topics/settings/ 6 | 7 | For the full list of settings and their values, see 8 | https://docs.djangoproject.com/en/1.7/ref/settings/ 9 | """ 10 | 11 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) 12 | import os 13 | BASE_DIR = os.path.dirname(os.path.dirname(__file__)) 14 | 15 | 16 | # Quick-start development settings - unsuitable for production 17 | # See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ 18 | 19 | # SECURITY WARNING: keep the secret key used in production secret! 20 | SECRET_KEY = '=$p(eb$m+7*2t2&b#om@vh4&#v@0po&phjvy#9)-b!tor)i-us' 21 | 22 | # SECURITY WARNING: don't run with debug turned on in production! 23 | DEBUG = True 24 | 25 | TEMPLATE_DEBUG = True 26 | 27 | ALLOWED_HOSTS = [] 28 | 29 | 30 | # Application definition 31 | 32 | INSTALLED_APPS = ( 33 | 'django.contrib.admin', 34 | 'django.contrib.auth', 35 | 'django.contrib.contenttypes', 36 | 'django.contrib.sessions', 37 | 'django.contrib.messages', 38 | 'django.contrib.staticfiles', 39 | ) 40 | 41 | MIDDLEWARE_CLASSES = ( 42 | 'django.contrib.sessions.middleware.SessionMiddleware', 43 | 'django.middleware.common.CommonMiddleware', 44 | 'django.middleware.csrf.CsrfViewMiddleware', 45 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 46 | 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 47 | 'django.contrib.messages.middleware.MessageMiddleware', 48 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 49 | ) 50 | 51 | ROOT_URLCONF = 'GEDCOMToJSONConverter.urls' 52 | 53 | WSGI_APPLICATION = 'GEDCOMToJSONConverter.wsgi.application' 54 | 55 | 56 | # Database 57 | # https://docs.djangoproject.com/en/1.7/ref/settings/#databases 58 | 59 | DATABASES = { 60 | 'default': { 61 | 'ENGINE': 'django.db.backends.sqlite3', 62 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 63 | } 64 | } 65 | 66 | # Internationalization 67 | # https://docs.djangoproject.com/en/1.7/topics/i18n/ 68 | 69 | LANGUAGE_CODE = 'en-us' 70 | 71 | TIME_ZONE = 'UTC' 72 | 73 | USE_I18N = True 74 | 75 | USE_L10N = True 76 | 77 | USE_TZ = True 78 | 79 | 80 | # Static files (CSS, JavaScript, Images) 81 | # https://docs.djangoproject.com/en/1.7/howto/static-files/ 82 | 83 | STATIC_URL = '/static/' 84 | -------------------------------------------------------------------------------- /GEDCOMToJSONConverter/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import patterns, include, url 2 | from django.contrib import admin 3 | 4 | urlpatterns = patterns('', 5 | # Examples: 6 | # url(r'^$', 'GEDCOMToJSONConverter.views.home', name='home'), 7 | # url(r'^blog/', include('blog.urls')), 8 | 9 | url(r'^admin/', include(admin.site.urls)), 10 | ) 11 | -------------------------------------------------------------------------------- /GEDCOMToJSONConverter/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for GEDCOMToJSONConverter project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "GEDCOMToJSONConverter.settings") 12 | 13 | from django.core.wsgi import get_wsgi_application 14 | application = get_wsgi_application() 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GEDCOMToJSONConverter 2 | -------------------------------------------------------------------------------- /converter/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PatKayongo/GEDCOMToJSONConverter/ab9b8b1abc46f7e8c47bf8ab0d42bb80faf945c1/converter/__init__.py -------------------------------------------------------------------------------- /converter/__pycache__/__init__.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PatKayongo/GEDCOMToJSONConverter/ab9b8b1abc46f7e8c47bf8ab0d42bb80faf945c1/converter/__pycache__/__init__.cpython-34.pyc -------------------------------------------------------------------------------- /converter/__pycache__/models.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PatKayongo/GEDCOMToJSONConverter/ab9b8b1abc46f7e8c47bf8ab0d42bb80faf945c1/converter/__pycache__/models.cpython-34.pyc -------------------------------------------------------------------------------- /converter/__pycache__/tests.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PatKayongo/GEDCOMToJSONConverter/ab9b8b1abc46f7e8c47bf8ab0d42bb80faf945c1/converter/__pycache__/tests.cpython-34.pyc -------------------------------------------------------------------------------- /converter/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /converter/business_logic/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PatKayongo/GEDCOMToJSONConverter/ab9b8b1abc46f7e8c47bf8ab0d42bb80faf945c1/converter/business_logic/__init__.py -------------------------------------------------------------------------------- /converter/business_logic/__pycache__/__init__.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PatKayongo/GEDCOMToJSONConverter/ab9b8b1abc46f7e8c47bf8ab0d42bb80faf945c1/converter/business_logic/__pycache__/__init__.cpython-34.pyc -------------------------------------------------------------------------------- /converter/business_logic/__pycache__/gedcom_parser.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PatKayongo/GEDCOMToJSONConverter/ab9b8b1abc46f7e8c47bf8ab0d42bb80faf945c1/converter/business_logic/__pycache__/gedcom_parser.cpython-34.pyc -------------------------------------------------------------------------------- /converter/business_logic/exceptions/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PatKayongo/GEDCOMToJSONConverter/ab9b8b1abc46f7e8c47bf8ab0d42bb80faf945c1/converter/business_logic/exceptions/__init__.py -------------------------------------------------------------------------------- /converter/business_logic/exceptions/__pycache__/__init__.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PatKayongo/GEDCOMToJSONConverter/ab9b8b1abc46f7e8c47bf8ab0d42bb80faf945c1/converter/business_logic/exceptions/__pycache__/__init__.cpython-34.pyc -------------------------------------------------------------------------------- /converter/business_logic/exceptions/__pycache__/invalid_file_exception.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PatKayongo/GEDCOMToJSONConverter/ab9b8b1abc46f7e8c47bf8ab0d42bb80faf945c1/converter/business_logic/exceptions/__pycache__/invalid_file_exception.cpython-34.pyc -------------------------------------------------------------------------------- /converter/business_logic/exceptions/invalid_file_exception.py: -------------------------------------------------------------------------------- 1 | 2 | class InvalidFileException(Exception): 3 | pass -------------------------------------------------------------------------------- /converter/business_logic/gedcom_parser.py: -------------------------------------------------------------------------------- 1 | from converter.business_logic.exceptions.invalid_file_exception import InvalidFileException 2 | from converter.models import Person, ParentRelationship, ParentRelationshipType 3 | 4 | class BaseElementParser: 5 | 6 | def parseElement(self, person): 7 | return None 8 | 9 | class PersonParser(BaseElementParser): 10 | 11 | def parseElement(self, fileLines, person): 12 | 13 | class GedcomParser: 14 | 15 | def __init__(self): 16 | 17 | 18 | def parseGedcomContent(self, fileContent): 19 | fileContent = fileContent.strip() 20 | fileLines = fileContent.splitlines() 21 | 22 | if (len(fileLines) == 0) or (fileLines[0].strip() != "0 HEAD"): 23 | raise InvalidFileException("The file has no HEAD") 24 | 25 | fileLines.pop(0) 26 | 27 | counter = 0 28 | while len(fileLines) > 0: 29 | if (fileLines[0].startswith("0")): 30 | 31 | 32 | person = Person() 33 | 34 | return person 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /converter/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PatKayongo/GEDCOMToJSONConverter/ab9b8b1abc46f7e8c47bf8ab0d42bb80faf945c1/converter/migrations/__init__.py -------------------------------------------------------------------------------- /converter/models.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | from django.db import models 3 | 4 | # Create your models here. 5 | 6 | class Person: 7 | name = None 8 | dateOfBirth = None 9 | sourceID = None 10 | isFemale = None 11 | parentRelationships = [] 12 | marriages = [] 13 | def __init__(self, name): 14 | self.name = name 15 | 16 | class MarriageStatus(Enum): 17 | Married = 1 18 | Divorced = 2 19 | 20 | class Marriage: 21 | marriageDate = None 22 | 23 | def __init__(self, husband, wife): 24 | self.husband = husband 25 | self.wife = wife 26 | 27 | class ParentRelationshipType(Enum): 28 | BiologicalMother = 1 29 | BiologicalFather = 2 30 | AdoptedMother = 3 31 | AdoptedFather = 4 32 | 33 | class ParentRelationship: 34 | def __init__(self, parent, relationshipType, child): 35 | self.parent = parent 36 | self.parentRelationshipType = relationshipType 37 | self.child = child -------------------------------------------------------------------------------- /converter/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PatKayongo/GEDCOMToJSONConverter/ab9b8b1abc46f7e8c47bf8ab0d42bb80faf945c1/converter/tests/__init__.py -------------------------------------------------------------------------------- /converter/tests/__pycache__/__init__.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PatKayongo/GEDCOMToJSONConverter/ab9b8b1abc46f7e8c47bf8ab0d42bb80faf945c1/converter/tests/__pycache__/__init__.cpython-34.pyc -------------------------------------------------------------------------------- /converter/tests/__pycache__/model_tests.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PatKayongo/GEDCOMToJSONConverter/ab9b8b1abc46f7e8c47bf8ab0d42bb80faf945c1/converter/tests/__pycache__/model_tests.cpython-34.pyc -------------------------------------------------------------------------------- /converter/tests/__pycache__/test_gedcom_parser.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PatKayongo/GEDCOMToJSONConverter/ab9b8b1abc46f7e8c47bf8ab0d42bb80faf945c1/converter/tests/__pycache__/test_gedcom_parser.cpython-34.pyc -------------------------------------------------------------------------------- /converter/tests/__pycache__/test_marriage.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PatKayongo/GEDCOMToJSONConverter/ab9b8b1abc46f7e8c47bf8ab0d42bb80faf945c1/converter/tests/__pycache__/test_marriage.cpython-34.pyc -------------------------------------------------------------------------------- /converter/tests/__pycache__/test_models.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PatKayongo/GEDCOMToJSONConverter/ab9b8b1abc46f7e8c47bf8ab0d42bb80faf945c1/converter/tests/__pycache__/test_models.cpython-34.pyc -------------------------------------------------------------------------------- /converter/tests/__pycache__/test_parent_relationship.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PatKayongo/GEDCOMToJSONConverter/ab9b8b1abc46f7e8c47bf8ab0d42bb80faf945c1/converter/tests/__pycache__/test_parent_relationship.cpython-34.pyc -------------------------------------------------------------------------------- /converter/tests/__pycache__/test_person.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PatKayongo/GEDCOMToJSONConverter/ab9b8b1abc46f7e8c47bf8ab0d42bb80faf945c1/converter/tests/__pycache__/test_person.cpython-34.pyc -------------------------------------------------------------------------------- /converter/tests/test_gedcom_parser.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | from converter.business_logic.gedcom_parser import GedcomParser 3 | from converter.business_logic.exceptions.invalid_file_exception import InvalidFileException 4 | from converter.models import Person, ParentRelationship, ParentRelationshipType 5 | 6 | class GedcomParserTestCase(TestCase): 7 | 8 | def setUp(self): 9 | self.parser = GedcomParser() 10 | 11 | def test_fileContentHasNoHead_exceptionThrown(self): 12 | 13 | fileContent = "1 INDI" 14 | 15 | with self.assertRaises(InvalidFileException) as contextManager: 16 | self.parser.parseGedcomContent(fileContent) 17 | 18 | exception = contextManager.exception 19 | self.assertEqual(str(exception), "The file has no HEAD") 20 | 21 | def test_fileHasPerson_PersonCreated(self): 22 | fileContent = "0 HEAD" 23 | fileContent = fileContent + " \n 0 @I1@ INDI" 24 | fileContent = fileContent + " \n 1 NAME Patrick" 25 | fileContent = fileContent + " \n 0 TRLR" 26 | 27 | people = self.parser.parseGedcomContent(fileContent) 28 | 29 | self.assertIsNotNone(people) 30 | self.assertEqual(people[0].name, "Patrick") 31 | 32 | 33 | -------------------------------------------------------------------------------- /converter/tests/test_marriage.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | from converter.models import Person, Marriage 5 | 6 | class MarriageTestCase(TestCase): 7 | 8 | def test_husband_and_wife_set_on_initialization(self): 9 | """Test husband and wife are set on initialization""" 10 | husband = Person("Michael") 11 | wife = Person("Mary") 12 | marriage = Marriage(husband, wife) 13 | 14 | self.assertEqual(marriage.husband, husband) 15 | self.assertEqual(marriage.wife, wife) -------------------------------------------------------------------------------- /converter/tests/test_parent_relationship.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | from converter.models import Person, ParentRelationship, ParentRelationshipType 3 | 4 | class ParentRelationshipTestCase(TestCase): 5 | 6 | def test_parent_and_child_set_on_initialization(self): 7 | parent = Person("daddy") 8 | relationshipType = ParentRelationshipType.BiologicalFather 9 | child = Person("child") 10 | relationship = ParentRelationship(parent, relationshipType, child) 11 | 12 | self.assertEqual(relationship.parent, parent) 13 | self.assertEqual(relationship.parentRelationshipType, relationshipType) 14 | self.assertEqual(relationship.child, child) -------------------------------------------------------------------------------- /converter/tests/test_person.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | from converter.models import Person 3 | 4 | class PersonTestCase(TestCase): 5 | def setUp(self): 6 | self.name = "name" 7 | 8 | def test_name_set_on_initialization(self): 9 | """Test name is set on initialization""" 10 | person = Person("Thando") 11 | self.assertEqual(person.name, "Thando") -------------------------------------------------------------------------------- /converter/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | 3 | # Create your views here. 4 | -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "GEDCOMToJSONConverter.settings") 7 | 8 | from django.core.management import execute_from_command_line 9 | 10 | execute_from_command_line(sys.argv) 11 | --------------------------------------------------------------------------------