Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ Documentation is in docs/. Examples of how to use this parser are at
docs/examples. If you find documentation and/or examples confusing,
let me know and I'll try to fix it.

Unit Tests
----------

Unit tests can be executed from the project root directory using:

PYTHONPATH=simplepyged python -m unittest discover

Licence
--------

Expand Down
4 changes: 2 additions & 2 deletions simplepyged/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Expand All @@ -39,7 +39,7 @@ def _get_value(self, tag):
return self.line.children_tags(tag)[0].value()
except IndexError:
return None

def dateplace(self):
""" Returns a pair of strings in format (date, place) """
date = ''
Expand Down
24 changes: 12 additions & 12 deletions simplepyged/gedcom.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Expand All @@ -28,7 +28,7 @@

# Global imports
import string
from records import *
from .records import *

class Gedcom:
""" Gedcom parser
Expand Down Expand Up @@ -109,11 +109,11 @@ def get_family(self, xref):
def _parse(self,file):
# open file
# go through the lines
f = open(file)
number = 1
for line in f.readlines():
self._parse_line(number,line.decode("utf-8-sig"))
number += 1
with open(file, encoding="utf-8-sig") as f:
for line in f.readlines():
self._parse_line(number, line)
number += 1

for e in self.line_list():
e._init()
Expand Down Expand Up @@ -146,7 +146,7 @@ def _parse_line(self,number,line):
t = self._tag(number,head) #retrieve line tag

v = tail #retrieve value of tag if it exists

# create the line
if l > self._current_level + 1:
self._error(number,"Structure of GEDCOM file is corrupted")
Expand Down Expand Up @@ -224,21 +224,21 @@ def _tag(self,number,head):
return head

def _error(self,number,text):
error = "Gedcom format error on line " + unicode(number) + ': ' + text
error = "Gedcom format error on line " + str(number) + ': ' + text
raise GedcomParseError(error)

def _print(self):
for e in self.line_list:
print string.join([unicode(e.level()),e.xref(),e.tag(),e.value()])
for e in self.line_list():
print(" ".join([str(e.level()),e.xref(),e.tag(),e.value()]))


class GedcomParseError(Exception):
""" Exception raised when a Gedcom parsing error occurs
"""

def __init__(self, value):
self.value = value

def __str__(self):
return self.value

12 changes: 6 additions & 6 deletions simplepyged/matches.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Expand All @@ -24,7 +24,7 @@
#
# To contact the author, see http://github.com/dijxtra/simplepyged

from records import Individual
from .records import Individual

class MatchIndividual():
""" Class for determining whether an Individual matches certain criteria """
Expand Down Expand Up @@ -81,7 +81,7 @@ def criteria_match(self,criteria):
* deathrange=[year1-year2]
* marriage=[year]
* marriagerange=[year1-year2]

"""

# error checking on the criteria
Expand Down Expand Up @@ -145,7 +145,7 @@ def criteria_match(self,criteria):
match = False
except ValueError:
match = False

return match

def marriage_year_match(self,year):
Expand Down Expand Up @@ -178,7 +178,7 @@ class MatchList:
gedcom = Gedcom(somefile)
list = gedcom.individual_list()
individual = gedcom.get_individual(xref)

if MatchIndividual(individual).given_match(some_name):
individual in MatchList(list).given_match(some_name) # this line returns True
"""
Expand All @@ -195,7 +195,7 @@ def __factory(self, method):
def product(*args):
return self.__abstract(method, *args)
return product

def __abstract(self, method, *args):
retval = []
for record in self.records:
Expand Down
Loading