* src/plugins/WriteGedcom.py (cl_setup): Define newline char.

* src/plugins/WriteFtree.py: Provide command line interface.
* src/gramps_main.py (handle_args): Add function. Add WFT export
format; (cl_export): Add WFT format.
* doc/gramps.1.in: Update man page to reflect new format option.
* doc/gramps.1: Likewise.
* NEWS: Likewise.
* TODO: Add recently discussed items from gramps-devel.


svn: r2133
This commit is contained in:
Alex Roitman 2003-09-16 01:35:09 +00:00
parent 8a3bd40f52
commit 4f738022e8
8 changed files with 199 additions and 165 deletions

View File

@ -1,3 +1,13 @@
2003-09-15 Alex Roitman <shura@alex.neuro.umn.edu>
* src/plugins/WriteGedcom.py (cl_setup): Define newline char.
* src/plugins/WriteFtree.py: Provide command line interface.
* src/gramps_main.py (handle_args): Add function. Add WFT export
format; (cl_export): Add WFT format.
* doc/gramps.1.in: Update man page to reflect new format option.
* doc/gramps.1: Likewise.
* NEWS: Likewise.
* TODO: Add recently discussed items from gramps-devel.
2003-09-14 Alex Roitman <shura@alex.neuro.umn.edu>
* src/SourceView.py (button_press,on_add_clicked,on_delete_clicked,
on_edit_clicked): Pass parent window to the child dialog.

View File

@ -30,7 +30,8 @@ Version 0.9.4 -- the "This used to bug me..." release
* User can choose between the usual (left to right) or alternative (top to
bottom) Family View.
* Support for graphics in Book Report.
* Fair share of bug fixes.
* Command line option for exporting to the Web Family Tree (-f wtf).
* Dozens of bug fixes.
Version 0.9.3
* New reports: Ancestors (text), Fan Chart (graphics), and

View File

@ -1,7 +1,12 @@
* Remember where the images are added from (RFE 748974). This is actually
very useful when you add 50 new images -- navigating 50 times to the same
place is a nightmare. All that's needed is keeping track of a single
last selected directory and then point gtk.FileSellector there.
* Add support for storing reliability (confidence) of the marriage information;
see http://sourceforge.net/mailarchive/forum.php?thread_id=3066997&forum_id=1993
and http://sourceforge.net/mailarchive/forum.php?thread_id=3134931&forum_id=1993
for the details.
* Work out the model and the interface for the completeness of a person,
see http://sourceforge.net/mailarchive/forum.php?thread_id=3127454&forum_id=1993
and http://sourceforge.net/mailarchive/forum.php?thread_id=3134932&forum_id=1993
for the details.
* Presense of Notes for a person/event/whatever_else. RFE 747527 suggested
either a column in the People View or something like boldfaces "Notes"

View File

@ -1,4 +1,4 @@
.TH gramps 1 "0.9.3" "July 2003" "0.9.3"
.TH gramps 1 "0.9.4" "September 2003" "0.9.4"
.SH NAME
gramps \- Genealogical Research and Analysis Management Programming System.
@ -45,7 +45,8 @@ directory), \fBgedcom\fR (guessed if \fIFILENAME\fR ends with \fB.ged\fR), and
.br
Formats available for export are \fBgramps\fR, \fBgedcom\fR, \fBgramps\-pkg\fR,
and \fBiso\fR (never guessed, always specify with \fB\-f\fR option).
\fBwft\fR (guessed if \fIFILENAME\fR ends with \fB.wft\fR), and \fBiso\fR
(never guessed, always specify with \fB\-f\fR option).
.TP
.BI \-i " FILENAME"
@ -65,8 +66,8 @@ gramps IDs in the resulting database.
.BI \-o " FILENAME"
Export data into \fIFILENAME\fR. For \fBgramps\fR and \fBiso\fR formats, the
\fIFILENAME\fR is actually the name of directory the gramps database will be
written into. For \fBgedcom\fR and \fBgramps\-pkg\fR, the \fIFILENAME\fR
is the name of the resulting file.
written into. For \fBgedcom\fR, \fBwft\fR, and \fBgramps\-pkg\fR,
the \fIFILENAME\fR is the name of the resulting file.
.br
When more than one output file is given, each has to be preceded
@ -106,11 +107,11 @@ of \fIstdout\fR and \fIstderr\fR to save messages and errors in files.
.SH EXAMPLES
.TP
To import three databases (whose formats can be determined from their names) and then check the resulting database for errors, one may type:
\fBgramps\fR \fB\-i\fR \fIfile1.ged\fR \fB\-i\fR \fIfile2.tgz\fR \fB\-i\fR \fI~/db3\fR \fB\-a\fR \fIcheck\fR
To import four databases (whose formats can be determined from their names) and then check the resulting database for errors, one may type:
\fBgramps\fR \fB\-i\fR \fIfile1.ged\fR \fB\-i\fR \fIfile2.tgz\fR \fB\-i\fR \fI~/db3\fR \fB\-i\fR \fIfile4.wft\fR \fB\-a\fR \fIcheck\fR
.TP
To explicitly specify the formats in the above example, append filenames with appropriate \fB\-f\fR options:
\fBgramps\fR \fB\-i\fR \fIfile1.ged\fR \fB\-f\fR \fIgedcom\fR \fB\-i\fR \fIfile2.tgz\fR \fB\-f\fR \fIgramps-pkg\fR \fB\-i\fR \fI~/dir3\fR \fB\-f\fR \fIgramps\fR \fB\-a\fR \fIcheck\fR
\fBgramps\fR \fB\-i\fR \fIfile1.ged\fR \fB\-f\fR \fIgedcom\fR \fB\-i\fR \fIfile2.tgz\fR \fB\-f\fR \fIgramps-pkg\fR \fB\-i\fR \fI~/db3\fR \fB\-f\fR \fIgramps\fR \fB\-i\fR \fIfile4.wft\fR \fB\-f\fR \fIwft\fR \fB\-a\fR \fIcheck\fR
.TP
To record the database resulting from all imports, supply \fB\-o\fR flag (use \fB\-f\fR if the filename does not allow gramps to guess the format):
\fBgramps\fR \fB\-i\fR \fIfile1.ged\fR \fB\-i\fR \fIfile2.tgz\fR \fB\-o\fR \fI~/new-package\fR \fB\-f\fR \fIgramps-pkg\fR

View File

@ -1,4 +1,4 @@
.TH gramps 1 "@VERSION@" "July 2003" "@VERSION@"
.TH gramps 1 "@VERSION@" "September 2003" "@VERSION@"
.SH NAME
gramps \- Genealogical Research and Analysis Management Programming System.
@ -45,7 +45,8 @@ directory), \fBgedcom\fR (guessed if \fIFILENAME\fR ends with \fB.ged\fR), and
.br
Formats available for export are \fBgramps\fR, \fBgedcom\fR, \fBgramps\-pkg\fR,
and \fBiso\fR (never guessed, always specify with \fB\-f\fR option).
\fBwft\fR (guessed if \fIFILENAME\fR ends with \fB.wft\fR), and \fBiso\fR
(never guessed, always specify with \fB\-f\fR option).
.TP
.BI \-i " FILENAME"
@ -65,8 +66,8 @@ gramps IDs in the resulting database.
.BI \-o " FILENAME"
Export data into \fIFILENAME\fR. For \fBgramps\fR and \fBiso\fR formats, the
\fIFILENAME\fR is actually the name of directory the gramps database will be
written into. For \fBgedcom\fR and \fBgramps\-pkg\fR, the \fIFILENAME\fR
is the name of the resulting file.
written into. For \fBgedcom\fR, \fBwft\fR, and \fBgramps\-pkg\fR,
the \fIFILENAME\fR is the name of the resulting file.
.br
When more than one output file is given, each has to be preceded
@ -106,11 +107,11 @@ of \fIstdout\fR and \fIstderr\fR to save messages and errors in files.
.SH EXAMPLES
.TP
To import three databases (whose formats can be determined from their names) and then check the resulting database for errors, one may type:
\fBgramps\fR \fB\-i\fR \fIfile1.ged\fR \fB\-i\fR \fIfile2.tgz\fR \fB\-i\fR \fI~/db3\fR \fB\-a\fR \fIcheck\fR
To import four databases (whose formats can be determined from their names) and then check the resulting database for errors, one may type:
\fBgramps\fR \fB\-i\fR \fIfile1.ged\fR \fB\-i\fR \fIfile2.tgz\fR \fB\-i\fR \fI~/db3\fR \fB\-i\fR \fIfile4.wft\fR \fB\-a\fR \fIcheck\fR
.TP
To explicitly specify the formats in the above example, append filenames with appropriate \fB\-f\fR options:
\fBgramps\fR \fB\-i\fR \fIfile1.ged\fR \fB\-f\fR \fIgedcom\fR \fB\-i\fR \fIfile2.tgz\fR \fB\-f\fR \fIgramps-pkg\fR \fB\-i\fR \fI~/dir3\fR \fB\-f\fR \fIgramps\fR \fB\-a\fR \fIcheck\fR
\fBgramps\fR \fB\-i\fR \fIfile1.ged\fR \fB\-f\fR \fIgedcom\fR \fB\-i\fR \fIfile2.tgz\fR \fB\-f\fR \fIgramps-pkg\fR \fB\-i\fR \fI~/db3\fR \fB\-f\fR \fIgramps\fR \fB\-i\fR \fIfile4.wft\fR \fB\-f\fR \fIwft\fR \fB\-a\fR \fIcheck\fR
.TP
To record the database resulting from all imports, supply \fB\-o\fR flag (use \fB\-f\fR if the filename does not allow gramps to guess the format):
\fBgramps\fR \fB\-i\fR \fIfile1.ged\fR \fB\-i\fR \fIfile2.tgz\fR \fB\-o\fR \fI~/new-package\fR \fB\-f\fR \fIgramps-pkg\fR

View File

@ -154,120 +154,7 @@ class Gramps:
self.init_interface()
if args:
try:
options,leftargs = getopt.getopt(args,
const.shortopts,const.longopts)
except getopt.GetoptError,msg:
print "Error: %s. Exiting." % msg
os._exit(1)
except:
print "Error parsing arguments: %s " % args
if leftargs:
print "Unrecognized option: %s" % leftargs[0]
os._exit(1)
exports = []
actions = []
imports = []
for opt_ix in range(len(options)):
o = options[opt_ix][0][1]
if o == '-':
continue
elif o == 'i':
fname = options[opt_ix][1]
if opt_ix<len(options)-1 and options[opt_ix+1][0][1]=='f':
format = options[opt_ix+1][1]
if format not in [ 'gedcom', 'gramps', 'gramps-pkg' ]:
print "Invalid format: %s" % format
os._exit(1)
elif fname[-3:].upper()== "GED":
format = 'gedcom'
elif fname[-3:].upper() == "TGZ":
format = 'gramps-pkg'
elif os.path.isdir(fname):
format = 'gramps'
else:
print "Unrecognized format for input file %s" % fname
os._exit(1)
imports.append((fname,format))
elif o == 'o':
outfname = options[opt_ix][1]
if opt_ix<len(options)-1 and options[opt_ix+1][0][1]=='f':
outformat = options[opt_ix+1][1]
if outformat not in [ 'gedcom', 'gramps', 'gramps-pkg', 'iso' ]:
print "Invalid format: %s" % outformat
os._exit(1)
elif outfname[-3:].upper() == "GED":
outformat = 'gedcom'
elif outfname[-3:].upper() == "TGZ":
outformat = 'gramps-pkg'
elif not os.path.isfile(outfname):
if not os.path.isdir(outfname):
try:
os.makedirs(outfname,0700)
except:
print "Cannot create directory %s" % outfname
os._exit(1)
outformat = 'gramps'
else:
print "Unrecognized format for output file %s" % outfname
os._exit(1)
exports.append((outfname,outformat))
elif o == 'a':
action = options[opt_ix][1]
if action not in [ 'check', 'summary' ]:
print "Unknown action: %s." % action
os._exit(1)
actions.append(action)
if imports:
self.cl = bool(exports or actions)
# Create dir for imported database(s)
self.impdir_path = os.path.expanduser("~/.gramps/import" )
if not os.path.isdir(self.impdir_path):
try:
os.mkdir(self.impdir_path,0700)
except:
print "Could not create import directory %s. Exiting." \
% self.impdir_path
os._exit(1)
elif not os.access(self.impdir_path,os.W_OK):
print "Import directory %s is not writable. Exiting." \
% self.impdir_path
os._exit(1)
# and clean it up before use
files = os.listdir(self.impdir_path) ;
for fn in files:
if os.path.isfile(os.path.join(self.impdir_path,fn)):
os.remove(os.path.join(self.impdir_path,fn))
self.clear_database(0)
self.db.setSavePath(self.impdir_path)
for imp in imports:
print "Importing: file %s, format %s." % (imp[0],imp[1])
self.cl_import(imp[0],imp[1])
else:
print "No data was given. Launching interactive session."
print "To use in the command-line mode,", \
"supply at least one input file to process."
if self.cl:
for expt in exports:
print "Exporting: file %s, format %s." % (expt[0],expt[1])
self.cl_export(expt[0],expt[1])
for action in actions:
print "Performing action: %s." % action
self.cl_action(action)
print "Cleaning up."
# clean import dir up after use
files = os.listdir(self.impdir_path) ;
for fn in files:
if os.path.isfile(os.path.join(self.impdir_path,fn)):
os.remove(os.path.join(self.impdir_path,fn))
print "Exiting."
os._exit(0)
self.handle_args(args)
elif GrampsCfg.lastfile and GrampsCfg.autoload:
self.auto_save_load(GrampsCfg.lastfile)
else:
@ -1195,6 +1082,123 @@ class Gramps:
self.apply_filter()
self.goto_active_person(1)
def handle_args(self,args):
try:
options,leftargs = getopt.getopt(args,
const.shortopts,const.longopts)
except getopt.GetoptError,msg:
print "Error: %s. Exiting." % msg
os._exit(1)
except:
print "Error parsing arguments: %s " % args
if leftargs:
print "Unrecognized option: %s" % leftargs[0]
os._exit(1)
exports = []
actions = []
imports = []
for opt_ix in range(len(options)):
o = options[opt_ix][0][1]
if o == '-':
continue
elif o == 'i':
fname = options[opt_ix][1]
if opt_ix<len(options)-1 and options[opt_ix+1][0][1]=='f':
format = options[opt_ix+1][1]
if format not in [ 'gedcom', 'gramps', 'gramps-pkg' ]:
print "Invalid format: %s" % format
os._exit(1)
elif fname[-3:].upper()== "GED":
format = 'gedcom'
elif fname[-3:].upper() == "TGZ":
format = 'gramps-pkg'
elif os.path.isdir(fname):
format = 'gramps'
else:
print "Unrecognized format for input file %s" % fname
os._exit(1)
imports.append((fname,format))
elif o == 'o':
outfname = options[opt_ix][1]
if opt_ix<len(options)-1 and options[opt_ix+1][0][1]=='f':
outformat = options[opt_ix+1][1]
if outformat not in [ 'gedcom', 'gramps', 'gramps-pkg', 'iso', 'wft' ]:
print "Invalid format: %s" % outformat
os._exit(1)
elif outfname[-3:].upper() == "GED":
outformat = 'gedcom'
elif outfname[-3:].upper() == "TGZ":
outformat = 'gramps-pkg'
elif outfname[-3:].upper() == "WFT":
outformat = 'wft'
elif not os.path.isfile(outfname):
if not os.path.isdir(outfname):
try:
os.makedirs(outfname,0700)
except:
print "Cannot create directory %s" % outfname
os._exit(1)
outformat = 'gramps'
else:
print "Unrecognized format for output file %s" % outfname
os._exit(1)
exports.append((outfname,outformat))
elif o == 'a':
action = options[opt_ix][1]
if action not in [ 'check', 'summary' ]:
print "Unknown action: %s." % action
os._exit(1)
actions.append(action)
if imports:
self.cl = bool(exports or actions)
# Create dir for imported database(s)
self.impdir_path = os.path.expanduser("~/.gramps/import" )
if not os.path.isdir(self.impdir_path):
try:
os.mkdir(self.impdir_path,0700)
except:
print "Could not create import directory %s. Exiting." \
% self.impdir_path
os._exit(1)
elif not os.access(self.impdir_path,os.W_OK):
print "Import directory %s is not writable. Exiting." \
% self.impdir_path
os._exit(1)
# and clean it up before use
files = os.listdir(self.impdir_path) ;
for fn in files:
if os.path.isfile(os.path.join(self.impdir_path,fn)):
os.remove(os.path.join(self.impdir_path,fn))
self.clear_database(0)
self.db.setSavePath(self.impdir_path)
for imp in imports:
print "Importing: file %s, format %s." % (imp[0],imp[1])
self.cl_import(imp[0],imp[1])
else:
print "No data was given. Launching interactive session."
print "To use in the command-line mode,", \
"supply at least one input file to process."
if self.cl:
for expt in exports:
print "Exporting: file %s, format %s." % (expt[0],expt[1])
self.cl_export(expt[0],expt[1])
for action in actions:
print "Performing action: %s." % action
self.cl_action(action)
print "Cleaning up."
# clean import dir up after use
files = os.listdir(self.impdir_path) ;
for fn in files:
if os.path.isfile(os.path.join(self.impdir_path,fn)):
os.remove(os.path.join(self.impdir_path,fn))
print "Exiting."
os._exit(0)
def cl_import(self,filename,format):
if format == 'gedcom':
import ReadGedcom
@ -1326,6 +1330,13 @@ class Gramps:
except:
print "Error exporting %s" % filename
os._exit(1)
elif format == 'wft':
import WriteFtree
try:
WriteFtree.FtreeWriter(self.db,None,1,filename)
except:
print "Error exporting %s" % filename
os._exit(1)
else:
print "Invalid format: %s" % format
os._exit(1)

View File

@ -73,52 +73,56 @@ def writeData(database,person):
#-------------------------------------------------------------------------
class FtreeWriter:
def __init__(self,database,person):
def __init__(self,database,person,cl=0,name=""):
self.db = database
base = os.path.dirname(__file__)
glade_file = "%s/%s" % (base,"writeftree.glade")
dic = {
"destroy_passed_object" : self.close,
"on_ok_clicked" : self.on_ok_clicked,
}
self.person = person
self.plist = {}
self.top = gtk.glade.XML(glade_file,"top","gramps")
Utils.set_titles(self.top.get_widget('top'),
if cl:
if name:
self.export(name,None,0)
else:
base = os.path.dirname(__file__)
glade_file = "%s/%s" % (base,"writeftree.glade")
dic = {
"destroy_passed_object" : self.close,
"on_ok_clicked" : self.on_ok_clicked,
}
self.top = gtk.glade.XML(glade_file,"top","gramps")
Utils.set_titles(self.top.get_widget('top'),
self.top.get_widget('title'),
_title_string)
self.top.signal_autoconnect(dic)
self.top.signal_autoconnect(dic)
self.topwin = self.top.get_widget("top")
self.restrict = self.top.get_widget("restrict")
self.filter = self.top.get_widget("filter")
self.topwin = self.top.get_widget("top")
self.restrict = self.top.get_widget("restrict")
self.filter = self.top.get_widget("filter")
all = GenericFilter.GenericFilter()
all.set_name(_("Entire Database"))
all.add_rule(GenericFilter.Everyone([]))
all = GenericFilter.GenericFilter()
all.set_name(_("Entire Database"))
all.add_rule(GenericFilter.Everyone([]))
des = GenericFilter.GenericFilter()
des.set_name(_("Descendants of %s") % person.getPrimaryName().getName())
des.add_rule(GenericFilter.IsDescendantOf([person.getId()]))
des = GenericFilter.GenericFilter()
des.set_name(_("Descendants of %s") % person.getPrimaryName().getName())
des.add_rule(GenericFilter.IsDescendantOf([person.getId()]))
ans = GenericFilter.GenericFilter()
ans.set_name(_("Ancestors of %s") % person.getPrimaryName().getName())
ans.add_rule(GenericFilter.IsAncestorOf([person.getId()]))
ans = GenericFilter.GenericFilter()
ans.set_name(_("Ancestors of %s") % person.getPrimaryName().getName())
ans.add_rule(GenericFilter.IsAncestorOf([person.getId()]))
com = GenericFilter.GenericFilter()
com.set_name(_("People with common ancestor with %s") %
com = GenericFilter.GenericFilter()
com.set_name(_("People with common ancestor with %s") %
person.getPrimaryName().getName())
com.add_rule(GenericFilter.HasCommonAncestorWith([person.getId()]))
com.add_rule(GenericFilter.HasCommonAncestorWith([person.getId()]))
self.filter_menu = GenericFilter.build_filter_menu([all,des,ans,com])
self.filter.set_menu(self.filter_menu)
self.filter_menu = GenericFilter.build_filter_menu([all,des,ans,com])
self.filter.set_menu(self.filter_menu)
self.topwin.show()
self.topwin.show()
def close(self,obj):
self.topwin.destroy()

View File

@ -542,6 +542,7 @@ class GedcomWriter:
self.source_refs = self.target_ged.get_source_refs()
self.cnvtxt = keep_utf8
self.nl = self.cnvtxt(self.target_ged.get_endl())
self.flist = {}
self.slist = {}