#!/usr/bin/env python
import re, sys, string, karpathos

from papafile import loadPapaFile
from GEDCOM import loadGEDCOMFile, saveGEDCOMFile
from HTML import saveHTMLFile


# papa_format.py
# --------------
#
# A program for genealogical processing of the matsakis family tree.
# Currently, this program can load from .papa files and dump to a few
# different formats: ASCII trees, individual data format, and GEDCOM
# files.
#
# Eventually, this file should become a module for a program which
# loads the data and produces HTML output as a response to a CGI query.
#
# This is the TODO list:
#
# papa file loading:
#  1. Add 'age' detection to birth / death times
#  2. Make the date detection detect a date after the word 'born' and
#     anywhere before the word 'died', and vice versa.
#
# gedcom output:
#  none
#
# html output:
#  all

builddebug = 0
        
if len(sys.argv) != 3:
    print "Usage; papa_format.py <inp file> <prettyprint|gedcom|html>"
    sys.exit(1)
    pass

f = open(sys.argv[1])
if not f:
    print "What kind of FUCKING JOKE IS THIS."
    print "Can't open: %s" % sys.argv[1]
    sys.exit(1)
    pass

pg = loadPapaFile (f)
if sys.argv[2] == "prettyprint": pg.prettyprint()
elif sys.argv[2] == "gedcom": saveGEDCOMFile (sys.stdout, pg)
elif sys.argv[2] == "html": saveHTMLFile (sys.stdout, pg)
else:
    print "Please specify an output method; prettyprint|gedcom|html"

