* src/ArgHandler.py (parse_args): Use mime type to identify gramps

XML data.
* doc/gramps.1.in: Update man page.
* doc/gramps-manual/C/cmdline.xml: Update manual.

* src/PeopleModel.py: provide a work around for the python 2.3 bug
unicode sorting problem with locale.strcoll. For a nul termination
during sorting, strip it off after sorting. Only used for
python2.3, since this bug was fixed in python 2.4.


svn: r5019
This commit is contained in:
Alex Roitman 2005-08-04 23:54:18 +00:00
parent b6e123ed06
commit 02f7142364
4 changed files with 72 additions and 75 deletions

View File

@ -13,12 +13,16 @@
* src/po/template.po: Update for upcoming 2.0.6.
* src/Report.py (parse_report_options_frame): Fallback to trivial
filter on filter failure.
* src/ArgHandler.py (parse_args): Use mime type to identify gramps
XML data.
* doc/gramps.1.in: Update man page.
* doc/gramps-manual/C/cmdline.xml: Update manual.
2005-08-04 Don Allingham <don@gramps-project.org>
* src/PeopleModel.py: provide a work around for the python 2.3 bug unicode
sorting problem with locale.strcoll. For a nul termination during sorting,
strip it off after sorting. Only used for python2.3, since this bug was
fixed in python 2.4.
* src/PeopleModel.py: provide a work around for the python 2.3 bug
unicode sorting problem with locale.strcoll. For a nul termination
during sorting, strip it off after sorting. Only used for
python2.3, since this bug was fixed in python 2.4.
2005-08-03 Don Allingham <don@gramps-project.org>
* src/NavWebPage.py: use new ProgressMeter, add ability to

View File

@ -70,7 +70,7 @@
<varlistentry><term>gramps-xml</term>
<listitem><para> &app; XML database. This format is available
for opening, import, and export. When not specified, it can be
guessed if the filename represents a directory.
guessed if the filename ends with .gramps
</para></listitem></varlistentry>
<varlistentry><term>gedcom</term>
@ -82,13 +82,13 @@
<varlistentry><term>gramps-pkg</term>
<listitem><para> &app; package. This format is available
for import and export. When not specified, it can be
guessed if the filename ends with .tgz
guessed if the filename ends with .gpkg
</para></listitem></varlistentry>
<varlistentry><term>geneweb</term>
<listitem><para> GeneWen file This format is available
for import and export. When not specified, it can be
guessed if the filename ends with gw
guessed if the filename ends with .gw
</para></listitem></varlistentry>
<varlistentry><term>wft</term>
@ -134,12 +134,7 @@
<command>--format=<replaceable>format</replaceable></command>
option, immediately following the <filename>filename</filename>.
If not specified, the guess will be attempted based on
the <filename>filename</filename>. For gramps-xml
format, the <filename>filename</filename> is actually the
name of directory under which the gramps database resides. For
grdb and gedcom,
the <filename>filename</filename> is the name of the
corresponding file.
the <filename>filename</filename>.
</para>
<tip><para>Only grdb, gramps-xml,
@ -163,12 +158,7 @@
<command>--format=<replaceable>format</replaceable></command>
option, immediately following the <filename>filename</filename>.
If not specified, the guess will be attempted based on
the <filename>filename</filename>. For gramps-xml
format, the <filename>filename</filename> is actually the
name of directory under which the gramps database resides. For
grdb, gedcom, gramps-pkg, and geneweb,
the <filename>filename</filename> is the name of the
corresponding file.
the <filename>filename</filename>.
</para>
<tip><para>More than one file can be imported in one command.
@ -195,10 +185,10 @@
option. The format can be specified with the <command>-f</command>
option immediately following the <filename>filename</filename>.
If not specified, the guess will be attempted based on
the <filename>filename</filename>. For gramps-xml
and iso formats, the <filename>filename</filename>
the <filename>filename</filename>. For iso format,
the <filename>filename</filename>
is actually the name of directory the gramps database will be written
into. For grdb, gedcom, wft, geneweb,
into. For grdb, gramps-xml, gedcom, wft, geneweb,
and gramps-pkg, the <filename>filename</filename>
is the name of the resulting file.
</para>
@ -411,8 +401,8 @@
<listitem>
<para><command>gramps
-i<filename>file1.ged</filename>
-i <filename>file2.tgz</filename>
-i <filename>~/db3</filename>
-i <filename>file2.gpkg</filename>
-i <filename>~/db3.gramps</filename>
-i <filename>file4.wft</filename>
-a <filename>check</filename></command>
</para> </listitem></varlistentry>
@ -424,10 +414,10 @@
<para><command>gramps
-i <filename>file1.ged</filename>
-f <replaceable>gedcom</replaceable>
-i <filename>file2.tgz</filename>
-i <filename>file2.gpkg</filename>
-f <replaceable>gramps-pkg</replaceable>
-i <filename>~/db3</filename>
-f <replaceable>gramps</replaceable>
-i <filename>~/db3.gramps</filename>
-f <replaceable>gramps-xml</replaceable>
-i <filename>file4.wft</filename>
-f <replaceable>wft</replaceable>
-a <replaceable>check</replaceable></command>
@ -441,7 +431,7 @@
<listitem>
<para><command>gramps
-i <filename>file1.ged</filename>
-i <filename>file2.tgz</filename>
-i <filename>file2.gpkg</filename>
-o <filename>~/new-package</filename>
-f <replaceable>gramps-pkg</replaceable></command>
</para></listitem>
@ -454,7 +444,7 @@
<listitem>
<para><command>gramps
-i <filename>file1.ged</filename>
-i <filename>file2.tgz</filename>
-i <filename>file2.dpkg</filename>
-o <filename>~/new-package</filename>
-f <replaceable>gramps-pkg</replaceable>
&gt;<filename>outfile</filename>
@ -468,8 +458,8 @@
<listitem>
<para><command>gramps
-i <filename>file1.ged</filename>
-i <filename>file2.tgz</filename>
-i <filename>~/db3</filename>
-i <filename>file2.gpkg</filename>
-i <filename>~/db3.gramps</filename>
</command>
</para> </listitem>
</varlistentry>

View File

@ -1,4 +1,4 @@
.TH gramps 1 "@VERSION@" "May 2005" "@VERSION@"
.TH gramps 1 "@VERSION@" "August 2005" "@VERSION@"
.SH NAME
gramps \- Genealogical Research and Analysis Management Programming System.
@ -59,8 +59,8 @@ the format of that file is guessed according to its extension.
Formats
available for opening are \fBgrdb\fR (guessed if \fIFILE\fR ends with
\fB.grdb\fR), \fBgramps\-xml\fR (guessed if \fIFILE\fR is a
directory), and \fBgedcom\fR (guessed if \fIFILE\fR ends with \fB.ged\fR).
\fB.grdb\fR), \fBgramps\-xml\fR (guessed if \fIFILE\fR ends with
\fB.gramps\fR), and \fBgedcom\fR (guessed if \fIFILE\fR ends with \fB.ged\fR).
.br
Formats
@ -80,10 +80,6 @@ Open \fIFILE\fR.
Only \fBgrdb\fR, \fBgramps\-xml\fR, and \fBgedcom\fR formats can be
opened directly. For other formats, you will need to use the import option
which will set up the empty database and then import data into it.
For \fBgramps\-xml\fR format, the \fIFILE\fR
is actually the name of directory under which the gramps database resides.
For \fBgrdb\fR and \fBgedcom\fR, the \fIFILE\fR is the name of
the corresponding file.
.br
Only a single file can be opened. If you need to combine data from several
@ -91,11 +87,7 @@ sources, you will need to use the import option.
.TP
.BI \-i,\-\^\-import= " FILE"
Import data from \fIFILE\fR. For \fBgramps\-xml\fR format, the \fIFILE\fR
is actually the name of directory under which the gramps database resides.
For \fBgrdb\fR, \fBgedcom\fR, \fBgramps\-pkg\fR, and \fBgeneweb\fR,
the \fIFILE\fR is
the name of the corresponding file.
Import data from \fIFILE\fR.
.br
When more than one input file is given, each has to be preceded by \fB\-i\fR
@ -106,9 +98,9 @@ gramps IDs in the resulting database.
.TP
.BI \-o,\-\^\-output= " FILE"
Export data into \fIFILE\fR. For \fBgramps\-xml\fR and \fBiso\fR formats, the
\fIFILE\fR is actually the name of directory the gramps database will be
written into. For \fBgrdb\fR, \fBgedcom\fR, \fBwft\fR, \fBgramps\-pkg\fR,
Export data into \fIFILE\fR. For \fBiso\fR format, the \fIFILE\fR is actually
the name of directory the gramps database will be written into.
For \fBgrdb\fR, \fBgramps\-xml\fR, \fBgedcom\fR, \fBwft\fR, \fBgramps\-pkg\fR,
and \fBgeneweb\fR, the \fIFILE\fR is the name of the resulting file.
.br
@ -205,16 +197,16 @@ of \fIstdout\fR and \fIstderr\fR to save messages and errors in files.
.SH EXAMPLES
.TP
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
\fBgramps\fR \fB\-i\fR \fIfile1.ged\fR \fB\-i\fR \fIfile2.tgz\fR \fB\-i\fR \fI~/db3.gramps\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~/db3\fR \fB\-f\fR \fIgramps\fR \fB\-i\fR \fIfile4.wft\fR \fB\-f\fR \fIwft\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.gramps\fR \fB\-f\fR \fIgramps-xml\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
.TP
To import three databases and start interactive gramps session with the result:
\fBgramps\fR \fB\-i\fR \fIfile1.ged\fR \fB\-i\fR \fIfile2.tgz\fR \fB\-i\fR \fI~/db3\fR
\fBgramps\fR \fB\-i\fR \fIfile1.ged\fR \fB\-i\fR \fIfile2.tgz\fR \fB\-i\fR \fI~/db3.gramps\fR
.TP
Finally, to start normal interactive session type:
\fBgramps\fR

View File

@ -127,7 +127,8 @@ class ArgHandler:
o,v = options[opt_ix]
if o in ( '-O', '--open'):
fname = v
ftype = GrampsMime.get_type(os.path.abspath(os.path.expanduser(fname)))
ftype = GrampsMime.get_type(
os.path.abspath(os.path.expanduser(fname)))
if opt_ix<len(options)-1 \
and options[opt_ix+1][0] in ( '-f', '--format'):
format = options[opt_ix+1][1]
@ -137,7 +138,7 @@ class ArgHandler:
continue
elif ftype == const.app_gedcom:
format = 'gedcom'
elif ftype == "x-directory/normal":
elif ftype == const.app_gramps_xml:
format = 'gramps-xml'
elif ftype == const.app_gramps:
format = 'grdb'
@ -148,11 +149,16 @@ class ArgHandler:
self.open = (fname,format)
elif o in ( '-i', '--import'):
fname = v
ftype = GrampsMime.get_type(os.path.abspath(os.path.expanduser(fname)))
ftype = GrampsMime.get_type(
os.path.abspath(os.path.expanduser(fname)))
if opt_ix<len(options)-1 \
and options[opt_ix+1][0] in ( '-f', '--format'):
format = options[opt_ix+1][1]
if format not in ('gedcom','gramps-xml','gramps-pkg','grdb','geneweb'):
if format not in ('gedcom',
'gramps-xml',
'gramps-pkg',
'grdb',
'geneweb'):
print "Invalid format: %s" % format
print "Ignoring input file: %s" % fname
continue
@ -160,7 +166,7 @@ class ArgHandler:
format = 'gedcom'
elif ftype == const.app_gramps_package:
format = 'gramps-pkg'
elif ftype == "x-directory/normal":
elif ftype == const.app_gramps_xml:
format = 'gramps-xml'
elif ftype == const.app_gramps:
format = 'grdb'
@ -176,7 +182,13 @@ class ArgHandler:
if opt_ix<len(options)-1 \
and options[opt_ix+1][0] in ( '-f', '--format'):
outformat = options[opt_ix+1][1]
if outformat not in ('gedcom','gramps-xml','gramps-pkg','grdb','iso','wft','geneweb'):
if outformat not in ('gedcom',
'gramps-xml',
'gramps-pkg',
'grdb',
'iso',
'wft',
'geneweb'):
print "Invalid format: %s" % outformat
print "Ignoring output file: %s" % outfname
continue
@ -188,14 +200,7 @@ class ArgHandler:
outformat = 'wft'
elif outfname[-2:].upper() == "GW":
outformat = 'geneweb'
elif not os.path.isfile(outfname):
if not os.path.isdir(outfname):
try:
os.makedirs(outfname,0700)
except:
print "Cannot create directory %s" % outfname
print "Ignoring output file: %s" % outfname
continue
elif outfname[-6:].upper() == "GRAMPS":
outformat = 'gramps-xml'
elif fname[-3:].upper() == "GRDB":
format = 'grdb'
@ -286,7 +291,8 @@ class ArgHandler:
if not prompter.chooser():
QuestionDialog.ErrorDialog(
_("New GRAMPS database was not set up"),
_('GRAMPS cannot open non-native data without setting up new GRAMPS database.'))
_('GRAMPS cannot open non-native data '
'without setting up new GRAMPS database.'))
print "Cannot continue without native database. Exiting..."
os._exit(1)
elif filetype == const.app_gramps_package:
@ -297,7 +303,9 @@ class ArgHandler:
print "Unknown file type: %s" % filetype
QuestionDialog.ErrorDialog(
_("Could not open file: %s") % filename,
_('File type "%s" is unknown to GRAMPS.\n\nValid types are: GRAMPS database, GRAMPS XML, GRAMPS package, and GEDCOM.') % filetype)
_('File type "%s" is unknown to GRAMPS.\n\n'
'Valid types are: GRAMPS database, GRAMPS XML, '
'GRAMPS package, and GEDCOM.') % filetype)
print "Exiting..."
os._exit(1)
if success:
@ -339,11 +347,13 @@ class ArgHandler:
os._exit(1)
if self.imports:
self.parent.cl = bool(self.exports or self.actions or self.parent.cl)
self.parent.cl = bool(self.exports or
self.actions or self.parent.cl)
# Create dir for imported database(s)
self.impdir_path = os.path.expanduser("~/.gramps/import" )
self.imp_db_path = os.path.expanduser("~/.gramps/import/import_db.grdb" )
self.imp_db_path = os.path.expanduser(
"~/.gramps/import/import_db.grdb" )
if not os.path.isdir(self.impdir_path):
try:
os.mkdir(self.impdir_path,0700)
@ -432,8 +442,7 @@ class ArgHandler:
os._exit(1)
elif format == 'gramps-xml':
try:
dbname = os.path.join(filename,const.xmlFile)
ReadXML.importData(self.parent.db,dbname,None,self.parent.cl)
ReadXML.importData(self.parent.db,filename,None,self.parent.cl)
except:
print "Error importing %s" % filename
os._exit(1)
@ -452,7 +461,8 @@ class ArgHandler:
try:
os.mkdir(tmpdir_path,0700)
except:
print "Could not create temporary directory %s" % tmpdir_path
print "Could not create temporary directory %s" \
% tmpdir_path
os._exit(1)
elif not os.access(tmpdir_path,os.W_OK):
print "Temporary directory %s is not writable" % tmpdir_path
@ -510,12 +520,11 @@ class ArgHandler:
os._exit(1)
elif format == 'gramps-xml':
filename = os.path.normpath(os.path.abspath(filename))
dbname = os.path.join(filename,const.xmlFile)
if filename:
try:
import WriteXML
g = WriteXML.XmlWriter(self.parent.db,None,1,1)
ret = g.write(dbname)
ret = g.write(filename)
except:
print "Error exporting %s" % filename
os._exit(1)
@ -546,7 +555,8 @@ class ArgHandler:
elif format == 'geneweb':
import WriteGeneWeb
try:
writer = WriteGeneWeb.GeneWebWriter(self.parent.db,None,1,filename)
writer = WriteGeneWeb.GeneWebWriter(self.parent.db,
None,1,filename)
ret = writer.export_data()
except:
print "Error exporting %s" % filename
@ -599,7 +609,8 @@ class ArgHandler:
options_class = item[3]
if category in (const.CATEGORY_BOOK,const.CATEGORY_CODE,
const.CATEGORY_WEB):
options_class(self.parent.db,name,category,options_str_dict)
options_class(self.parent.db,name,
category,options_str_dict)
else:
Report.cl_report(self.parent.db,name,category,
report_class,options_class,options_str_dict)