Merged trunk r17888 through r18397 into geps023.

Conflicts resolved in:
    /data/grampsxml.dtd
    /data/grampsxml.rng
    /src/Filters/Rules/Repository/_MatchesNameSubstringOf.py
    /src/plugins/import/ImportXml.py
(Various property conflicts also resolved)

svn: r18405
This commit is contained in:
Tim G L Lyons
2011-11-05 19:07:58 +00:00
431 changed files with 150048 additions and 89561 deletions

View File

@@ -13,7 +13,8 @@ pkgdata_PYTHON = \
arghandler.py \
argparser.py \
clidbman.py \
grampscli.py
grampscli.py \
user.py
pkgpyexecdir = @pkgpyexecdir@/cli
pkgpythondir = @pkgpythondir@/cli

View File

@@ -192,7 +192,7 @@ class ArgParser(object):
1/ Just the family tree (name or database dir)
2/ -O, --open: Open of a family tree
3/ -i, --import: Import a family tree of any format understood by an importer,
optionally provide-f to indicate format
optionally provide -f to indicate format
4/ -e, --export: export a family tree in required format, optionally provide
-f to indicate format
5/ -f, --format=FORMAT : format after a -i or -e option

View File

@@ -19,7 +19,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id:gramps_main.py 9912 2008-01-22 09:17:46Z acraphae $
# $Id$
"""
Provides the startcli function, which the main program calls for CLI

View File

@@ -62,6 +62,7 @@ from gen.plug.report._paper import paper_sizes
import const
import DbState
from cli.grampscli import CLIManager
import cli.user
#------------------------------------------------------------------------
#
@@ -559,7 +560,7 @@ def cl_report(database, name, category, report_class, options_class,
if clr.css_filename is not None and \
hasattr(clr.option_class.handler.doc, 'set_css_filename'):
clr.option_class.handler.doc.set_css_filename(clr.css_filename)
MyReport = report_class(database, clr.option_class)
MyReport = report_class(database, clr.option_class, cli.user.User())
MyReport.doc.init()
MyReport.begin_report()
MyReport.write_report()
@@ -604,7 +605,7 @@ def run_report(db, name, **options_str_dict):
"""
dbstate = DbState.DbState()
climanager = CLIManager(dbstate, False) # don't load db
climanager.do_reg_plugins()
climanager.do_reg_plugins(dbstate, None)
pmgr = BasePluginManager.get_instance()
cl_list = pmgr.get_reg_reports()
clr = None

140
src/cli/user.py Normal file
View File

@@ -0,0 +1,140 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2010 Brian G. Matherly
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# 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
#
# $Id: user.py 18393 2011-10-31 16:46:50Z paul-franklin $
#
"""
The User class provides basic interaction with the user.
"""
#------------------------------------------------------------------------
#
# Python Modules
#
#------------------------------------------------------------------------
import sys
#------------------------------------------------------------------------
#
# Gramps Modules
#
#------------------------------------------------------------------------
import gen.user
#------------------------------------------------------------------------
#
# Private Constants
#
#------------------------------------------------------------------------
_SPINNER = ['|', '/', '-', '\\']
#-------------------------------------------------------------------------
#
# User class
#
#-------------------------------------------------------------------------
class User(gen.user.User):
"""
This class provides a means to interact with the user via CLI.
It implements the interface in gen.user.User()
"""
def __init__(self):
self.steps = 0;
self.current_step = 0;
def begin_progress(self, title, message, steps):
"""
Start showing a progress indicator to the user.
@param title: the title of the progress meter
@type title: str
@param message: the message associated with the progress meter
@type message: str
@param steps: the total number of steps for the progress meter. a value
of 0 indicates that the ending is unknown and the meter should just
show activity.
@type steps: int
@returns: none
"""
print message
self.steps = steps
self.current_step = 0;
if self.steps == 0:
sys.stdout.write(_SPINNER[self.current_step])
else:
sys.stdout.write("00%")
def step_progress(self):
"""
Advance the progress meter.
"""
self.current_step += 1
if self.steps == 0:
self.current_step %= 4
sys.stdout.write("\r %s " % _SPINNER[self.current_step])
else:
percent = int((float(self.current_step) / self.steps) * 100)
sys.stdout.write("\r%02d%%" % percent)
def end_progress(self):
"""
Start showing a progress indicator to the user.
"""
if self.steps != 0:
sys.stdout.write("\r100%")
sys.stdout.write("\n")
def prompt(self, title, question):
"""
Ask the user a question. The answer must be "yes" or "no". The user will
be forced to answer the question before proceeding.
@param title: the title of the question
@type title: str
@param question: the question
@type question: str
@returns: the user's answer to the question
@rtype: bool
"""
return False
def warn(self, title, warning):
"""
Warn the user.
@param title: the title of the warning
@type title: str
@param warning: the warning
@type warning: str
@returns: none
"""
print "%s %s" % (title, warning)
def notify_error(self, title, error):
"""
Notify the user of an error.
@param title: the title of the error
@type title: str
@param error: the error message
@type error: str
@returns: none
"""
print "%s %s" % (title, warning)