Пример #1
0
class Report:
    """
    The Report base class.  This is a base class for generating
    customized reports.  It cannot be used as is, but it can be easily
    sub-classed to create a functional report generator.
    """

    def __init__(self, database, options_class, user):
        self.database = database
        self.options_class = options_class

        self.doc = options_class.get_document()

        creator = database.get_researcher().get_name()
        self.doc.set_creator(creator)

        output = options_class.get_output()
        if output:
            self.standalone = True
            self.doc.open(options_class.get_output())
        else:
            self.standalone = False

    def begin_report(self):
        pass

    def set_locale(self, language):
        """
        Set the translator to one selected with
        stdoptions.add_localization_option().
        """
        if language == Locale.DEFAULT_TRANSLATION_STR:
            language = None
        locale = Locale(lang=language)
        self._ = locale.translation.sgettext
        self._get_date = locale.get_date
        self._get_type = locale.get_type
        self._ldd = locale.date_displayer
        self._name_display = NameDisplay(locale) # a legacy/historical name
        self._name_display.set_name_format(self.database.name_formats)
        fmt_default = config.get('preferences.name-format')
        self._name_display.set_default_format(fmt_default)
        return locale

    def write_report(self):
        pass

    def end_report(self):
        if self.standalone:
            self.doc.close()
Пример #2
0
 def set_locale(self, language):
     """
     Set the translator to one selected with
     stdoptions.add_localization_option().
     """
     if language == Locale.DEFAULT_TRANSLATION_STR:
         language = None
     locale = Locale(lang=language)
     self._ = locale.translation.sgettext
     self._get_date = locale.get_date
     self._get_type = locale.get_type
     self._ldd = locale.date_displayer
     self._name_display = NameDisplay(locale) # a legacy/historical name
     self._name_display.set_name_format(self.database.name_formats)
     fmt_default = config.get('preferences.name-format')
     self._name_display.set_default_format(fmt_default)
     return locale
Пример #3
0
# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#

# Gramps imports:
from gprime.lib.person import Person
from gprime.display.name import NameDisplay

# Gramps Connect imports:
from .forms import Form

# Globals:
nd = NameDisplay().display

class PersonForm(Form):
    """
    A form for listing, viewing, and editing a Person object.
    """
    _class = Person
    view = "person"
    tview = "People"
    table = "Person"

    # Fields for editor:
    edit_fields = [
        "primary_name.type",
        "primary_name.title",
        "primary_name.nick",
Пример #4
0
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#

# gPrime imports:
from gprime.plugins.lib.libhtml import Html
from gprime.lib import *
from gprime.lib.struct import Struct
from gprime.display.name import NameDisplay
from gprime.datehandler import displayer

# Python imports:
import tornado.log

# Globals and functions:
TAB_HEIGHT = 200
name_display = NameDisplay().display
date_display = displayer.display


def nbsp(string):
    """
    """
    if string:
        return string
    else:
        return " "


class Table(object):
    """
    >>> table = Table(form)