more report pylint improvements

This commit is contained in:
Paul Franklin
2016-06-05 21:11:27 -07:00
parent 21d02ad22c
commit 042bb5e2c0
14 changed files with 581 additions and 523 deletions

View File

@@ -40,10 +40,10 @@ import sys
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
try: try:
from xml.sax import make_parser, handler,SAXParseException from xml.sax import make_parser, handler, SAXParseException
from xml.sax.saxutils import quoteattr from xml.sax.saxutils import quoteattr
except: except:
from _xmlplus.sax import make_parser, handler,SAXParseException from _xmlplus.sax import make_parser, handler, SAXParseException
from _xmlplus.sax.saxutils import quoteattr from _xmlplus.sax.saxutils import quoteattr
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@@ -88,7 +88,7 @@ class OptionList:
""" """
return self.options return self.options
def set_option(self, name,value): def set_option(self, name, value):
""" """
Set a particular option in the OptionList. Set a particular option in the OptionList.
@@ -118,7 +118,7 @@ class OptionList:
:returns: value associated with the passed option :returns: value associated with the passed option
:rtype: str :rtype: str
""" """
return self.options.get(name,None) return self.options.get(name, None)
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@@ -130,7 +130,7 @@ class OptionListCollection:
Implements a collection of option lists. Implements a collection of option lists.
""" """
def __init__(self,filename): def __init__(self, filename):
""" """
Create an OptionListCollection instance from the list defined Create an OptionListCollection instance from the list defined
in the specified file. in the specified file.
@@ -167,7 +167,7 @@ class OptionListCollection:
or None of no such option exists or None of no such option exists
:rtype: str :rtype: str
""" """
return self.option_list_map.get(name,None) return self.option_list_map.get(name, None)
def get_module_names(self): def get_module_names(self):
""" """
@@ -189,13 +189,13 @@ class OptionListCollection:
""" """
self.option_list_map[name] = option_list self.option_list_map[name] = option_list
def write_common(self,f): def write_common(self, filename):
""" """
Stub function for common options. Overridden by reports. Stub function for common options. Overridden by reports.
""" """
pass pass
def write_module_common(self,f, option_list): def write_module_common(self, filename, option_list):
""" """
Stub function for common options. Overridden by reports. Stub function for common options. Overridden by reports.
""" """
@@ -205,54 +205,55 @@ class OptionListCollection:
""" """
Saves the current OptionListCollection to the associated file. Saves the current OptionListCollection to the associated file.
""" """
f = io.open(self.filename,"w", encoding="utf-8") file = io.open(self.filename, "w", encoding="utf-8")
f.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n") file.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
f.write('<options>\n') file.write('<options>\n')
self.write_common(f) self.write_common(file)
for module_name in sorted(self.get_module_names()): # enable a diff for module_name in sorted(self.get_module_names()): # enable a diff
option_list = self.get_option_list(module_name) option_list = self.get_option_list(module_name)
module_docgen_opts = {} module_docgen_opts = {}
for docgen_name in self.docgen_names: for docgen_name in self.docgen_names:
module_docgen_opts[docgen_name] = [] module_docgen_opts[docgen_name] = []
f.write('<module name=%s>\n' % quoteattr(module_name)) file.write('<module name=%s>\n' % quoteattr(module_name))
options = option_list.get_options() options = option_list.get_options()
for option_name in sorted(options.keys()): # enable a diff for option_name in sorted(options.keys()): # enable a diff
option_data = options[option_name] option_data = options[option_name]
if isinstance(option_data, (list, tuple)): if isinstance(option_data, (list, tuple)):
if option_data and option_data[0] in self.docgen_names: if option_data and option_data[0] in self.docgen_names:
module_docgen_opts[option_data[0]].append( module_docgen_opts[option_data[0]].append(
(option_name, option_data[1])) (option_name, option_data[1]))
else: else:
f.write(' <option name=%s ' file.write(' <option name=%s '
'value="" length="%d">\n' % ( 'value="" length="%d">\n'
quoteattr(option_name), % (quoteattr(option_name),
len(option_data) ) ) len(option_data)))
for list_index, list_data in enumerate(option_data): for list_index, list_data in enumerate(option_data):
f.write(' <listitem ' file.write(' <listitem '
'number="%d" value=%s/>\n' % ( 'number="%d" value=%s/>\n'
list_index, % (list_index,
quoteattr(str(list_data))) ) quoteattr(str(list_data))))
f.write(' </option>\n') file.write(' </option>\n')
else: else:
f.write(' <option name=%s value=%s/>\n' % ( file.write(' <option name=%s value=%s/>\n'
quoteattr(option_name), % (quoteattr(option_name),
quoteattr(str(option_data))) ) quoteattr(str(option_data))))
for docgen_name in self.docgen_names: for docgen_name in self.docgen_names:
if module_docgen_opts[docgen_name]: if module_docgen_opts[docgen_name]:
for ix, data in enumerate(module_docgen_opts[docgen_name]): for idx, data in enumerate(
f.write(' <docgen-option docgen=%s ' module_docgen_opts[docgen_name]):
'name=%s value=%s/>\n' % file.write(' <docgen-option docgen=%s '
(quoteattr(docgen_name), 'name=%s value=%s/>\n'
quoteattr(data[0]), % (quoteattr(docgen_name),
quoteattr(str(data[1])) )) quoteattr(data[0]),
self.write_module_common(f, option_list) quoteattr(str(data[1]))))
self.write_module_common(file, option_list)
f.write('</module>\n') file.write('</module>\n')
f.write('</options>\n') file.write('</options>\n')
f.close() file.close()
def parse(self): def parse(self):
""" """
@@ -260,10 +261,10 @@ class OptionListCollection:
""" """
try: try:
if os.path.isfile(self.filename): if os.path.isfile(self.filename):
p = make_parser() parser = make_parser()
p.setContentHandler(OptionParser(self)) parser.setContentHandler(OptionParser(self))
p.parse(self.filename) parser.parse(self.filename)
except (IOError,OSError,SAXParseException): except (IOError, OSError, SAXParseException):
pass pass
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@@ -276,7 +277,7 @@ class OptionParser(handler.ContentHandler):
SAX parsing class for the OptionListCollection XML file. SAX parsing class for the OptionListCollection XML file.
""" """
def __init__(self,collection): def __init__(self, collection):
""" """
Create a OptionParser class that populates the passed collection. Create a OptionParser class that populates the passed collection.
@@ -288,18 +289,18 @@ class OptionParser(handler.ContentHandler):
self.mname = None self.mname = None
self.option_list = None self.option_list = None
self.oname = None self.oname = None
self.o = None self.odict = None
self.an_o = None self.an_o = None
self.list_class = OptionList self.list_class = OptionList
def startElement(self,tag,attrs): def startElement(self, tag, attrs):
""" """
Overridden class that handles the start of a XML element Overridden class that handles the start of a XML element
""" """
if tag in ("report","module"): if tag in ("report", "module"):
self.mname = attrs['name'] self.mname = attrs['name']
self.option_list = self.list_class() self.option_list = self.list_class()
self.o = {} self.odict = {}
elif tag == "option": elif tag == "option":
self.oname = attrs['name'] self.oname = attrs['name']
if 'length' in attrs: if 'length' in attrs:
@@ -309,13 +310,13 @@ class OptionParser(handler.ContentHandler):
elif tag == "listitem": elif tag == "listitem":
self.an_o.append(attrs['value']) self.an_o.append(attrs['value'])
def endElement(self,tag): def endElement(self, tag):
"Overridden class that handles the end of a XML element" "Overridden class that handles the end of a XML element"
if tag == "option": if tag == "option":
self.o[self.oname] = self.an_o self.odict[self.oname] = self.an_o
elif tag in ("report","module"): elif tag in ("report", "module"):
self.option_list.set_options(self.o) self.option_list.set_options(self.odict)
self.collection.set_option_list(self.mname,self.option_list) self.collection.set_option_list(self.mname, self.option_list)
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@@ -327,7 +328,7 @@ class OptionHandler:
Implements handling of the options for the plugins. Implements handling of the options for the plugins.
""" """
def __init__(self,module_name, options_dict,person_id=None): def __init__(self, module_name, options_dict, person_id=None):
self.module_name = module_name self.module_name = module_name
self.default_options_dict = options_dict.copy() self.default_options_dict = options_dict.copy()
self.options_dict = options_dict self.options_dict = options_dict
@@ -336,7 +337,8 @@ class OptionHandler:
self.init_subclass() self.init_subclass()
self.option_list_collection = self.collection_class(self.filename) self.option_list_collection = self.collection_class(self.filename)
self.init_common() self.init_common()
self.saved_option_list = self.option_list_collection.get_option_list(module_name) self.saved_option_list = self.option_list_collection.get_option_list(
module_name)
self.person_id = person_id self.person_id = person_id
# Whatever was found should override the defaults # Whatever was found should override the defaults
@@ -383,14 +385,14 @@ class OptionHandler:
docgen_names = self.option_list_collection.docgen_names docgen_names = self.option_list_collection.docgen_names
for option_name in bad_opts: for option_name in bad_opts:
option_data = options[option_name] option_data = options[option_name]
if not ( isinstance(option_data, list) and if not (isinstance(option_data, list)
option_data and and option_data
option_data[0] in docgen_names ): and option_data[0] in docgen_names):
print(_("Option '%(opt_name)s' is present in %(file)s\n" print(_("Option '%(opt_name)s' is present in %(file)s\n"
" but is not known to the module. Ignoring...") % " but is not known to the module. Ignoring..."
{ 'opt_name' : option_name, % {'opt_name' : option_name,
'file' : self.option_list_collection.filename }, 'file' : self.option_list_collection.filename}),
file=sys.stderr ) file=sys.stderr)
options.pop(option_name) options.pop(option_name)
# Then we set common options from whatever was found # Then we set common options from whatever was found
@@ -412,7 +414,8 @@ class OptionHandler:
if option_data == self.default_options_dict[option_name]: if option_data == self.default_options_dict[option_name]:
self.saved_option_list.remove_option(option_name) self.saved_option_list.remove_option(option_name)
else: else:
self.saved_option_list.set_option(option_name,self.options_dict[option_name]) self.saved_option_list.set_option(
option_name, self.options_dict[option_name])
# Handle common options # Handle common options
self.save_common_options() self.save_common_options()
@@ -426,7 +429,7 @@ class OptionHandler:
def get_person_id(self): def get_person_id(self):
return self.person_id return self.person_id
def set_person_id(self,val): def set_person_id(self, val):
self.person_id = val self.person_id = val
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@@ -443,7 +446,7 @@ class Options:
classes should derive from it. classes should derive from it.
""" """
def __init__(self, name,person_id=None): def __init__(self, name, person_id=None):
""" """
Initialize the class, performing usual house-keeping tasks. Initialize the class, performing usual house-keeping tasks.
Subclasses MUST call this in their __init__() method. Subclasses MUST call this in their __init__() method.
@@ -478,7 +481,8 @@ class Options:
Modifies all options to have the value they were last used as. Modifies all options to have the value they were last used as.
Call this function after all options have been added. Call this function after all options have been added.
""" """
self.handler = OptionHandler(self.name,self.options_dict,self.person_id) self.handler = OptionHandler(
self.name, self.options_dict, self.person_id)
def add_user_options(self): def add_user_options(self):
""" """
@@ -529,7 +533,7 @@ class MenuOptions:
for name in self.menu.get_all_option_names(): for name in self.menu.get_all_option_names():
option = self.menu.get_option_by_name(name) option = self.menu.get_option_by_name(name)
self.options_dict[name] = option.get_value() self.options_dict[name] = option.get_value()
self.options_help[name] = [ "", option.get_help() ] self.options_help[name] = ["", option.get_help()]
def make_default_style(self, default_style): def make_default_style(self, default_style):
""" """
@@ -553,7 +557,7 @@ class MenuOptions:
""" """
self.menu.add_option(category, name, option) self.menu.add_option(category, name, option)
self.options_dict[name] = option.get_value() self.options_dict[name] = option.get_value()
self.options_help[name] = [ "", option.get_help() ] self.options_help[name] = ["", option.get_help()]
def add_user_options(self): def add_user_options(self):
""" """

View File

@@ -36,8 +36,8 @@ import os
import copy import copy
from xml.sax.saxutils import escape from xml.sax.saxutils import escape
def escxml(d): def escxml(word):
return escape(d, { '"' : '&quot;' } ) return escape(word, {'"' : '&quot;'})
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@@ -445,56 +445,62 @@ class OptionListCollection(_options.OptionListCollection):
""" """
return self.last_format_name return self.last_format_name
def write_common(self, f): def write_common(self, file):
f.write('<last-common>\n') file.write('<last-common>\n')
if self.get_last_paper_metric() != self.default_paper_metric: if self.get_last_paper_metric() != self.default_paper_metric:
f.write(' <metric value="%d"/>\n' % self.get_last_paper_metric() ) file.write(' <metric value="%d"/>\n'
% self.get_last_paper_metric())
if self.get_last_custom_paper_size() != self.default_custom_paper_size: if self.get_last_custom_paper_size() != self.default_custom_paper_size:
size = self.get_last_custom_paper_size() size = self.get_last_custom_paper_size()
f.write(' <size value="%f %f"/>\n' % (size[0], size[1]) ) file.write(' <size value="%f %f"/>\n' % (size[0], size[1]))
if self.get_last_paper_name() != self.default_paper_name: if self.get_last_paper_name() != self.default_paper_name:
f.write(' <paper name="%s"/>\n' % escxml(self.get_last_paper_name()) ) file.write(' <paper name="%s"/>\n'
% escxml(self.get_last_paper_name()))
if self.get_last_css_filename() != self.default_css_filename: if self.get_last_css_filename() != self.default_css_filename:
f.write(' <css name="%s"/>\n' % escxml(self.get_last_css_filename()) ) file.write(' <css name="%s"/>\n'
% escxml(self.get_last_css_filename()))
if self.get_last_format_name() != self.default_format_name: if self.get_last_format_name() != self.default_format_name:
f.write(' <format name="%s"/>\n' % escxml(self.get_last_format_name()) ) file.write(' <format name="%s"/>\n'
% escxml(self.get_last_format_name()))
if self.get_last_orientation() != self.default_orientation: if self.get_last_orientation() != self.default_orientation:
f.write(' <orientation value="%d"/>\n' % self.get_last_orientation() ) file.write(' <orientation value="%d"/>\n'
f.write('</last-common>\n') % self.get_last_orientation())
file.write('</last-common>\n')
def write_module_common(self, f, option_list): def write_module_common(self, file, option_list):
if option_list.get_format_name(): if option_list.get_format_name():
f.write(' <format name="%s"/>\n' % file.write(' <format name="%s"/>\n'
escxml(option_list.get_format_name()) ) % escxml(option_list.get_format_name()))
if option_list.get_format_name() == 'html': if option_list.get_format_name() == 'html':
if option_list.get_css_filename(): if option_list.get_css_filename():
f.write(' <css name="%s"/>\n' % file.write(' <css name="%s"/>\n'
escxml(option_list.get_css_filename())) % escxml(option_list.get_css_filename()))
else: # not HTML format, therefore it's paper else: # not HTML format, therefore it's paper
if option_list.get_paper_name(): if option_list.get_paper_name():
f.write(' <paper name="%s"/>\n' % file.write(' <paper name="%s"/>\n'
escxml(option_list.get_paper_name()) ) % escxml(option_list.get_paper_name()))
if option_list.get_orientation() is not None: # 0 is legal if option_list.get_orientation() is not None: # 0 is legal
f.write(' <orientation value="%d"/>\n' % file.write(' <orientation value="%d"/>\n'
option_list.get_orientation() ) % option_list.get_orientation())
if option_list.get_paper_metric() is not None: # 0 is legal if option_list.get_paper_metric() is not None: # 0 is legal
f.write(' <metric value="%d"/>\n' % file.write(' <metric value="%d"/>\n'
option_list.get_paper_metric() ) % option_list.get_paper_metric())
if option_list.get_custom_paper_size(): if option_list.get_custom_paper_size():
size = option_list.get_custom_paper_size() size = option_list.get_custom_paper_size()
f.write(' <size value="%f %f"/>\n' % (size[0], size[1]) ) file.write(' <size value="%f %f"/>\n'
% (size[0], size[1]))
if option_list.get_margins(): if option_list.get_margins():
margins = option_list.get_margins() margins = option_list.get_margins()
for pos in range(len(margins)): for pos in range(len(margins)):
f.write(' <margin number="%s" value="%f"/>\n' % file.write(' <margin number="%s" value="%f"/>\n'
(pos, margins[pos])) % (pos, margins[pos]))
if option_list.get_style_name(): if option_list.get_style_name():
f.write(' <style name="%s"/>\n' % file.write(' <style name="%s"/>\n'
escxml(option_list.get_style_name()) ) % escxml(option_list.get_style_name()))
if option_list.get_output(): if option_list.get_output():
f.write(' <output name="%s"/>\n' % file.write(' <output name="%s"/>\n'
escxml(os.path.basename(option_list.get_output())) ) % escxml(os.path.basename(option_list.get_output())))
def parse(self): def parse(self):
""" """
@@ -502,10 +508,10 @@ class OptionListCollection(_options.OptionListCollection):
""" """
try: try:
if os.path.isfile(self.filename): if os.path.isfile(self.filename):
p = make_parser() parser = make_parser()
p.setContentHandler(OptionParser(self)) parser.setContentHandler(OptionParser(self))
with open(self.filename, encoding="utf-8") as the_file: with open(self.filename, encoding="utf-8") as the_file:
p.parse(the_file) parser.parse(the_file)
except (IOError, OSError, SAXParseException): except (IOError, OSError, SAXParseException):
pass pass
@@ -595,7 +601,7 @@ class OptionParser(_options.OptionParser):
if tag == "last-common": if tag == "last-common":
self.common = False self.common = False
elif tag == 'docgen-option': elif tag == 'docgen-option':
self.o[self.oname] = self.an_o self.odict[self.oname] = self.an_o
else: else:
# Tag is not report-specific, so we let the base class handle it. # Tag is not report-specific, so we let the base class handle it.
_options.OptionParser.endElement(self, tag) _options.OptionParser.endElement(self, tag)
@@ -651,7 +657,8 @@ class OptionHandler(_options.OptionHandler):
self.paper_metric = self.option_list_collection.get_last_paper_metric() self.paper_metric = self.option_list_collection.get_last_paper_metric()
self.paper_name = self.option_list_collection.get_last_paper_name() self.paper_name = self.option_list_collection.get_last_paper_name()
self.orientation = self.option_list_collection.get_last_orientation() self.orientation = self.option_list_collection.get_last_orientation()
self.custom_paper_size = self.option_list_collection.get_last_custom_paper_size() self.custom_paper_size = \
self.option_list_collection.get_last_custom_paper_size()
self.css_filename = self.option_list_collection.get_last_css_filename() self.css_filename = self.option_list_collection.get_last_css_filename()
self.margins = self.option_list_collection.get_last_margins() self.margins = self.option_list_collection.get_last_margins()
self.format_name = self.option_list_collection.get_last_format_name() self.format_name = self.option_list_collection.get_last_format_name()
@@ -662,7 +669,8 @@ class OptionHandler(_options.OptionHandler):
if self.saved_option_list.get_orientation() is not None: # 0 is legal if self.saved_option_list.get_orientation() is not None: # 0 is legal
self.orientation = self.saved_option_list.get_orientation() self.orientation = self.saved_option_list.get_orientation()
if self.saved_option_list.get_custom_paper_size(): if self.saved_option_list.get_custom_paper_size():
self.custom_paper_size = self.saved_option_list.get_custom_paper_size() self.custom_paper_size = \
self.saved_option_list.get_custom_paper_size()
if self.saved_option_list.get_margins(): if self.saved_option_list.get_margins():
self.margins = self.saved_option_list.get_margins() self.margins = self.saved_option_list.get_margins()
if self.saved_option_list.get_css_filename(): if self.saved_option_list.get_css_filename():
@@ -709,7 +717,8 @@ class OptionHandler(_options.OptionHandler):
# Then save last-common options from the current selection # Then save last-common options from the current selection
self.option_list_collection.set_last_orientation(self.orientation) self.option_list_collection.set_last_orientation(self.orientation)
self.option_list_collection.set_last_custom_paper_size(self.custom_paper_size) self.option_list_collection.set_last_custom_paper_size(
self.custom_paper_size)
self.option_list_collection.set_last_margins(self.margins) self.option_list_collection.set_last_margins(self.margins)
self.option_list_collection.set_last_paper_metric(self.paper_metric) self.option_list_collection.set_last_paper_metric(self.paper_metric)
self.option_list_collection.set_last_paper_name(self.paper_name) self.option_list_collection.set_last_paper_name(self.paper_name)
@@ -724,27 +733,35 @@ class OptionHandler(_options.OptionHandler):
return os.path.join(HOME_DIR, filename) return os.path.join(HOME_DIR, filename)
def get_default_stylesheet_name(self): def get_default_stylesheet_name(self):
""" get the default stylesheet name """
return self.style_name return self.style_name
def set_default_stylesheet_name(self, style_name): def set_default_stylesheet_name(self, style_name):
""" set the default stylesheet name """
self.style_name = style_name self.style_name = style_name
def get_format_name(self): def get_format_name(self):
""" get the format name """
return self.format_name return self.format_name
def set_format_name(self, format_name): def set_format_name(self, format_name):
""" set the format name """
self.format_name = format_name self.format_name = format_name
def get_paper_metric(self): def get_paper_metric(self):
""" get the paper metric """
return self.paper_metric return self.paper_metric
def set_paper_metric(self, paper_metric): def set_paper_metric(self, paper_metric):
""" set the paper metric """
self.paper_metric = paper_metric self.paper_metric = paper_metric
def get_paper_name(self): def get_paper_name(self):
""" get the paper name """
return self.paper_name return self.paper_name
def set_paper_name(self, paper_name): def set_paper_name(self, paper_name):
""" set the paper name """
self.paper_name = paper_name self.paper_name = paper_name
def get_paper(self): def get_paper(self):
@@ -760,27 +777,35 @@ class OptionHandler(_options.OptionHandler):
self.paper = paper self.paper = paper
def get_css_filename(self): def get_css_filename(self):
""" get the CSS filename """
return self.css_filename return self.css_filename
def set_css_filename(self, css_filename): def set_css_filename(self, css_filename):
""" set the CSS filename """
self.css_filename = css_filename self.css_filename = css_filename
def get_orientation(self): def get_orientation(self):
""" get the paper's orientation """
return self.orientation return self.orientation
def set_orientation(self, orientation): def set_orientation(self, orientation):
""" set the paper's orientation """
self.orientation = orientation self.orientation = orientation
def get_custom_paper_size(self): def get_custom_paper_size(self):
""" get the paper's custom paper size, if any """
return copy.copy(self.custom_paper_size) return copy.copy(self.custom_paper_size)
def set_custom_paper_size(self, custom_paper_size): def set_custom_paper_size(self, custom_paper_size):
""" set the paper's custom paper size """
self.custom_paper_size = copy.copy(custom_paper_size) self.custom_paper_size = copy.copy(custom_paper_size)
def get_margins(self): def get_margins(self):
""" get the paper's margin sizes """
return copy.copy(self.margins) return copy.copy(self.margins)
def set_margins(self,margins): def set_margins(self, margins):
""" set the paper's margin sizes """
self.margins = copy.copy(margins) self.margins = copy.copy(margins)
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@@ -943,13 +968,13 @@ class DocOptionHandler(_options.OptionHandler):
options = self.saved_option_list.get_options() options = self.saved_option_list.get_options()
docgen_names = self.option_list_collection.docgen_names docgen_names = self.option_list_collection.docgen_names
for option_name, option_data in options.items(): for option_name, option_data in options.items():
if ( option_name in self.options_dict and if (option_name in self.options_dict
isinstance(option_data, list) and and isinstance(option_data, list)
option_data and and option_data
option_data[0] in docgen_names ): and option_data[0] in docgen_names):
try: try:
converter = get_type_converter( converter = get_type_converter(
self.options_dict[option_name]) self.options_dict[option_name])
self.options_dict[option_name] = converter(option_data[1]) self.options_dict[option_name] = converter(option_data[1])
except (TypeError, ValueError): except (TypeError, ValueError):
pass pass
@@ -997,10 +1022,10 @@ class DocOptionListCollection(_options.OptionListCollection):
""" """
try: try:
if os.path.isfile(self.filename): if os.path.isfile(self.filename):
p = make_parser() parser = make_parser()
p.setContentHandler(DocOptionParser(self)) parser.setContentHandler(DocOptionParser(self))
with open(self.filename, encoding="utf-8") as the_file: with open(self.filename, encoding="utf-8") as the_file:
p.parse(the_file) parser.parse(the_file)
except (IOError, OSError, SAXParseException): except (IOError, OSError, SAXParseException):
pass pass
@@ -1034,6 +1059,6 @@ class DocOptionParser(_options.OptionParser):
def endElement(self, tag): def endElement(self, tag):
"Overridden class that handles the end of a XML element" "Overridden class that handles the end of a XML element"
if tag == 'docgen-option': if tag == 'docgen-option':
self.o[self.oname] = self.an_o self.odict[self.oname] = self.an_o
else: else:
_options.OptionParser.endElement(self, tag) _options.OptionParser.endElement(self, tag)

View File

@@ -68,6 +68,7 @@ from gramps.gen.proxy import CacheProxyDb
#------------------------------------------------------------------------ #------------------------------------------------------------------------
def draw_wedge(doc, style, centerx, centery, radius, start_angle, def draw_wedge(doc, style, centerx, centery, radius, start_angle,
end_angle, short_radius=0): end_angle, short_radius=0):
""" draw a wedge """
from math import pi, cos, sin from math import pi, cos, sin
while end_angle < start_angle: while end_angle < start_angle:
@@ -92,24 +93,24 @@ def draw_wedge(doc, style, centerx, centery, radius, start_angle,
path.append((origx, origy)) path.append((origx, origy))
while angle < eangle: while angle < eangle:
x = centerx + cos(angle) * radius _x_ = centerx + cos(angle) * radius
y = centery + sin(angle) * radius _y_ = centery + sin(angle) * radius
path.append((x, y)) path.append((_x_, _y_))
angle = angle + radiansdelta angle = angle + radiansdelta
x = centerx + cos(eangle) * radius _x_ = centerx + cos(eangle) * radius
y = centery + sin(eangle) * radius _y_ = centery + sin(eangle) * radius
path.append((x, y)) path.append((_x_, _y_))
if short_radius: if short_radius:
x = centerx + cos(eangle) * short_radius _x_ = centerx + cos(eangle) * short_radius
y = centery + sin(eangle) * short_radius _y_ = centery + sin(eangle) * short_radius
path.append((x, y)) path.append((_x_, _y_))
angle = eangle angle = eangle
while angle >= sangle: while angle >= sangle:
x = centerx + cos(angle) * short_radius _x_ = centerx + cos(angle) * short_radius
y = centery + sin(angle) * short_radius _y_ = centery + sin(angle) * short_radius
path.append((x, y)) path.append((_x_, _y_))
angle -= radiansdelta angle -= radiansdelta
doc.draw_path(style, path) doc.draw_path(style, path)
@@ -198,8 +199,8 @@ def draw_legend(doc, start_x, start_y, data, title, label_style):
start_x + (3*size), start_y - (size*0.25)) start_x + (3*size), start_y - (size*0.25))
start_y += size * 1.3 start_y += size * 1.3
_t = time.localtime(time.time()) _TTT = time.localtime(time.time())
_TODAY = parser.parse("%04d-%02d-%02d" % _t[:3]) _TODAY = parser.parse("%04d-%02d-%02d" % _TTT[:3])
def estimate_age(dbase, person, def estimate_age(dbase, person,
end_handle=None, start_handle=None, today=_TODAY): end_handle=None, start_handle=None, today=_TODAY):
@@ -322,6 +323,7 @@ def _T_(value): # enable deferred translations (see Python docs 22.1.3.4)
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class Extract: class Extract:
""" Class for extracting statistical data from the database """
def __init__(self): def __init__(self):
"""Methods for extracting statistical data from the database""" """Methods for extracting statistical data from the database"""
@@ -396,7 +398,7 @@ class Extract:
def get_surname(self, person): def get_surname(self, person):
"return surnames for given person" "return surnames for given person"
# TODO: return all surnames, not just primary ones... # TODO: return all surnames, not just primary ones...
# TODO: have the surname fromatted according to the name_format too # TODO: have the surname formatted according to the name_format too
surnames = person.get_primary_name().get_surname().strip() surnames = person.get_primary_name().get_surname().strip()
if surnames: if surnames:
return surnames.split() return surnames.split()
@@ -720,6 +722,7 @@ _Extract = Extract()
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class StatisticsChart(Report): class StatisticsChart(Report):
""" StatisticsChart report """
def __init__(self, database, options, user): def __init__(self, database, options, user):
""" """
@@ -765,8 +768,8 @@ class StatisticsChart(Report):
if value == living_value: if value == living_value:
living_desc = self._(description) living_desc = self._(description)
break break
self.living_desc = self._("(Living people: %(option_name)s)" self.living_desc = self._(
% {'option_name': living_desc}) "(Living people: %(option_name)s)") % {'option_name': living_desc}
# title needs both data extraction method name + gender name # title needs both data extraction method name + gender name
if gender == Person.MALE: if gender == Person.MALE:
@@ -957,11 +960,13 @@ class StatisticsChart(Report):
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class StatisticsChartOptions(MenuReportOptions): class StatisticsChartOptions(MenuReportOptions):
""" Options for StatisticsChart report """
def __init__(self, name, dbase): def __init__(self, name, dbase):
self.__pid = None self.__pid = None
self.__filter = None self.__filter = None
self.__db = dbase self.__db = dbase
self._nf = None
MenuReportOptions.__init__(self, name, dbase) MenuReportOptions.__init__(self, name, dbase)
def add_menu_options(self, menu): def add_menu_options(self, menu):

View File

@@ -36,7 +36,6 @@ from gramps.gen.plug.menu import (PersonOption, FilterOption,
EnumeratedListOption) EnumeratedListOption)
from gramps.gen.plug.report import Report from gramps.gen.plug.report import Report
from gramps.gen.plug.report import utils as ReportUtils from gramps.gen.plug.report import utils as ReportUtils
pt2cm = ReportUtils.pt2cm
from gramps.gen.plug.report import MenuReportOptions from gramps.gen.plug.report import MenuReportOptions
from gramps.gen.plug.report import stdoptions from gramps.gen.plug.report import stdoptions
from gramps.gen.plug.docgen import (FontStyle, ParagraphStyle, GraphicsStyle, from gramps.gen.plug.docgen import (FontStyle, ParagraphStyle, GraphicsStyle,
@@ -52,7 +51,6 @@ from gramps.gen.proxy import CacheProxyDb
# private constants # private constants
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
cal = config.get('preferences.calendar-format-report')
# _T_ is a gramps-defined keyword -- see po/update_po.py and po/genpot.sh # _T_ is a gramps-defined keyword -- see po/update_po.py and po/genpot.sh
def _T_(value): # enable deferred translations (see Python docs 22.1.3.4) def _T_(value): # enable deferred translations (see Python docs 22.1.3.4)
@@ -73,6 +71,7 @@ def _get_sort_functions(sort):
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class TimeLine(Report): class TimeLine(Report):
""" TimeLine Report """
def __init__(self, database, options, user): def __init__(self, database, options, user):
""" """
@@ -115,8 +114,8 @@ class TimeLine(Report):
if value == living_value: if value == living_value:
living_desc = self._(description) living_desc = self._(description)
break break
self.living_desc = self._("(Living people: %(option_name)s)" self.living_desc = self._(
% {'option_name': living_desc}) "(Living people: %(option_name)s)") % {'option_name': living_desc}
stdoptions.run_name_format_option(self, menu) stdoptions.run_name_format_option(self, menu)
@@ -148,7 +147,7 @@ class TimeLine(Report):
st_size = self.name_size() st_size = self.name_size()
style_sheet = self.doc.get_style_sheet() style_sheet = self.doc.get_style_sheet()
font = style_sheet.get_paragraph_style('TLG-Name').get_font() font = style_sheet.get_paragraph_style('TLG-Name').get_font()
incr = pt2cm(font.get_size()) incr = ReportUtils.pt2cm(font.get_size())
pad = incr * 0.75 pad = incr * 0.75
_x1, _x2, _y1, _y2 = (0, 0, 0, 0) _x1, _x2, _y1, _y2 = (0, 0, 0, 0)
start = st_size + 0.5 start = st_size + 0.5
@@ -285,9 +284,9 @@ class TimeLine(Report):
self.doc.center_text('TLG-title', title, width / 2.0, 0, mark) self.doc.center_text('TLG-title', title, width / 2.0, 0, mark)
style_sheet = self.doc.get_style_sheet() style_sheet = self.doc.get_style_sheet()
title_font = style_sheet.get_paragraph_style('TLG-Title').get_font() title_font = style_sheet.get_paragraph_style('TLG-Title').get_font()
title_y = 1.2 - (pt2cm(title_font.get_size()) * 1.2) title_y = 1.2 - (ReportUtils.pt2cm(title_font.get_size()) * 1.2)
self.doc.center_text('TLG-title', self.fil_name, width / 2.0, title_y) self.doc.center_text('TLG-title', self.fil_name, width / 2.0, title_y)
title_y = 1.8 - (pt2cm(title_font.get_size()) * 1.2) title_y = 1.8 - (ReportUtils.pt2cm(title_font.get_size()) * 1.2)
self.doc.center_text('TLG-title', title3, width / 2.0, title_y) self.doc.center_text('TLG-title', title3, width / 2.0, title_y)
def draw_year_headings(self, year_low, year_high, start_pos, stop_pos): def draw_year_headings(self, year_low, year_high, start_pos, stop_pos):
@@ -296,7 +295,7 @@ class TimeLine(Report):
""" """
style_sheet = self.doc.get_style_sheet() style_sheet = self.doc.get_style_sheet()
label_font = style_sheet.get_paragraph_style('TLG-Label').get_font() label_font = style_sheet.get_paragraph_style('TLG-Label').get_font()
label_y = self.header - (pt2cm(label_font.get_size()) * 1.2) label_y = self.header - (ReportUtils.pt2cm(label_font.get_size()) * 1.2)
incr = (year_high - year_low) / 5 incr = (year_high - year_low) / 5
delta = (stop_pos - start_pos) / 5 delta = (stop_pos - start_pos) / 5
for val in range(0, 6): for val in range(0, 6):
@@ -311,7 +310,7 @@ class TimeLine(Report):
width = self.doc.get_usable_width() width = self.doc.get_usable_width()
style_sheet = self.doc.get_style_sheet() style_sheet = self.doc.get_style_sheet()
label_font = style_sheet.get_paragraph_style('TLG-Label').get_font() label_font = style_sheet.get_paragraph_style('TLG-Label').get_font()
label_y = self.header - (pt2cm(label_font.get_size()) * 1.2) label_y = self.header - (ReportUtils.pt2cm(label_font.get_size()) * 1.2)
self.doc.center_text('TLG-label', self._("No Date Information"), self.doc.center_text('TLG-label', self._("No Date Information"),
width / 2.0, label_y) width / 2.0, label_y)
@@ -391,7 +390,7 @@ class TimeLine(Report):
person = self.database.get_person_from_handle(p_id) person = self.database.get_person_from_handle(p_id)
dname = self._name_display.display(person) dname = self._name_display.display(person)
size = max(self.doc.string_width(font, dname), size) size = max(self.doc.string_width(font, dname), size)
return pt2cm(size) return ReportUtils.pt2cm(size)
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@@ -399,6 +398,7 @@ class TimeLine(Report):
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class TimeLineOptions(MenuReportOptions): class TimeLineOptions(MenuReportOptions):
""" Options for the TimeLine Report """
def __init__(self, name, dbase): def __init__(self, name, dbase):
self.__pid = None self.__pid = None

View File

@@ -46,7 +46,6 @@ from gramps.gen.plug.report import Report
from gramps.gen.plug.report import utils as ReportUtils from gramps.gen.plug.report import utils as ReportUtils
from gramps.gen.plug.report import MenuReportOptions from gramps.gen.plug.report import MenuReportOptions
from gramps.gen.plug.report import stdoptions from gramps.gen.plug.report import stdoptions
from gramps.gen.datehandler import get_date
from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback
from gramps.gen.proxy import CacheProxyDb from gramps.gen.proxy import CacheProxyDb
@@ -55,10 +54,9 @@ from gramps.gen.proxy import CacheProxyDb
# Constant options items # Constant options items
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
_COLORS = [ { 'name' : _("B&W outline"), 'value' : "outline" }, _COLORS = [{'name' : _("B&W outline"), 'value' : "outline"},
{ 'name' : _("Colored outline"), 'value' : "colored" }, {'name' : _("Colored outline"), 'value' : "colored"},
{ 'name' : _("Color fill"), 'value' : "filled" }] {'name' : _("Color fill"), 'value' : "filled"}]
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@@ -95,11 +93,11 @@ class HourGlassReport(Report):
self.__family_mother = [] # links allocated from family to mother self.__family_mother = [] # links allocated from family to mother
self.max_descend = menu.get_option_by_name('maxdescend').get_value() self.max_descend = menu.get_option_by_name('maxdescend').get_value()
self.max_ascend = menu.get_option_by_name('maxascend').get_value() self.max_ascend = menu.get_option_by_name('maxascend').get_value()
pid = menu.get_option_by_name('pid').get_value() pid = menu.get_option_by_name('pid').get_value()
self.center_person = self.__db.get_person_from_gramps_id(pid) self.center_person = self.__db.get_person_from_gramps_id(pid)
if (self.center_person == None) : if self.center_person is None:
raise ReportError(_("Person %s is not in the Database") % pid ) raise ReportError(_("Person %s is not in the Database") % pid)
# Would be nice to get rid of these 2 hard-coded arrays of colours # Would be nice to get rid of these 2 hard-coded arrays of colours
# and instead allow the user to pick-and-choose whatever colour they # and instead allow the user to pick-and-choose whatever colour they
@@ -146,7 +144,7 @@ class HourGlassReport(Report):
for family_handle in person.get_family_handle_list(): for family_handle in person.get_family_handle_list():
family = self.__db.get_family_from_handle(family_handle) family = self.__db.get_family_from_handle(family_handle)
self.add_family(family) self.add_family(family)
self.doc.add_link( person.get_gramps_id(), family.get_gramps_id() ) self.doc.add_link(person.get_gramps_id(), family.get_gramps_id())
for child_ref in family.get_child_ref_list(): for child_ref in family.get_child_ref_list():
child_handle = child_ref.get_reference_handle() child_handle = child_ref.get_reference_handle()
if child_handle not in self.__used_people: if child_handle not in self.__used_people:
@@ -155,7 +153,7 @@ class HourGlassReport(Report):
child = self.__db.get_person_from_handle(child_handle) child = self.__db.get_person_from_handle(child_handle)
self.add_person(child) self.add_person(child)
self.doc.add_link(family.get_gramps_id(), self.doc.add_link(family.get_gramps_id(),
child.get_gramps_id() ) child.get_gramps_id())
self.traverse_down(child, gen+1) self.traverse_down(child, gen+1)
def traverse_up(self, person, gen): def traverse_up(self, person, gen):
@@ -169,8 +167,8 @@ class HourGlassReport(Report):
family = self.__db.get_family_from_handle(family_handle) family = self.__db.get_family_from_handle(family_handle)
family_id = family.get_gramps_id() family_id = family.get_gramps_id()
self.add_family(family) self.add_family(family)
self.doc.add_link( family_id, person.get_gramps_id(), self.doc.add_link(family_id, person.get_gramps_id(),
head='none', tail='normal' ) head='none', tail='normal')
# create link from family to father # create link from family to father
father_handle = family.get_father_handle() father_handle = family.get_father_handle()
@@ -179,8 +177,8 @@ class HourGlassReport(Report):
self.__family_father.append(family_handle) self.__family_father.append(family_handle)
father = self.__db.get_person_from_handle(father_handle) father = self.__db.get_person_from_handle(father_handle)
self.add_person(father) self.add_person(father)
self.doc.add_link( father.get_gramps_id(), family_id, self.doc.add_link(father.get_gramps_id(), family_id,
head='none', tail='normal' ) head='none', tail='normal')
# no need to go up if he is a father in another family # no need to go up if he is a father in another family
if father_handle not in self.__used_people: if father_handle not in self.__used_people:
self.__used_people.append(father_handle) self.__used_people.append(father_handle)
@@ -191,10 +189,10 @@ class HourGlassReport(Report):
if mother_handle and family_handle not in self.__family_mother: if mother_handle and family_handle not in self.__family_mother:
# allocate only one mother per family # allocate only one mother per family
self.__family_mother.append(family_handle) self.__family_mother.append(family_handle)
mother = self.__db.get_person_from_handle( mother_handle ) mother = self.__db.get_person_from_handle(mother_handle)
self.add_person( mother ) self.add_person(mother)
self.doc.add_link( mother.get_gramps_id(), family_id, self.doc.add_link(mother.get_gramps_id(), family_id,
head='none', tail='normal' ) head='none', tail='normal')
# no need to go up if she is a mother in another family # no need to go up if she is a mother in another family
if mother_handle not in self.__used_people: if mother_handle not in self.__used_people:
self.__used_people.append(mother_handle) self.__used_people.append(mother_handle)
@@ -341,16 +339,14 @@ class HourGlassOptions(MenuReportOptions):
################################ ################################
color = EnumeratedListOption(_("Graph coloring"), "filled") color = EnumeratedListOption(_("Graph coloring"), "filled")
for i in range( 0, len(_COLORS) ): for i in range(0, len(_COLORS)):
color.add_item(_COLORS[i]["value"], _COLORS[i]["name"]) color.add_item(_COLORS[i]["value"], _COLORS[i]["name"])
color.set_help(_("Males will be shown with blue, females " color.set_help(_("Males will be shown with blue, females "
"with red. If the sex of an individual " "with red. If the sex of an individual "
"is unknown it will be shown with gray.")) "is unknown it will be shown with gray."))
menu.add_option(category_name, "color", color) menu.add_option(category_name, "color", color)
roundedcorners = BooleanOption( # see bug report #2180 roundedcorners = BooleanOption(_("Use rounded corners"), False) # 2180
_("Use rounded corners"), False)
roundedcorners.set_help( roundedcorners.set_help(
_("Use rounded corners to differentiate " _("Use rounded corners to differentiate between women and men."))
"between women and men."))
menu.add_option(category_name, "roundcorners", roundedcorners) menu.add_option(category_name, "roundcorners", roundedcorners)

View File

@@ -20,6 +20,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
""" custom text for the book report """
# Written by Alex Roitman, # Written by Alex Roitman,
# largely based on the SimpleBookTitle.py by Don Allingham # largely based on the SimpleBookTitle.py by Don Allingham
@@ -55,6 +57,7 @@ from gramps.gen.plug.docgen import (FontStyle, ParagraphStyle,
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class CustomText(Report): class CustomText(Report):
""" CustomText """
def __init__(self, database, options, user): def __init__(self, database, options, user):
""" """
@@ -125,19 +128,19 @@ class CustomTextOptions(MenuReportOptions):
category_name = _("Text") category_name = _("Text")
top = TextOption(_("Initial Text"), [""] ) top = TextOption(_("Initial Text"), [""])
top.set_help(_("Text to display at the top.")) top.set_help(_("Text to display at the top."))
menu.add_option(category_name, "top", top) menu.add_option(category_name, "top", top)
mid = TextOption(_("Middle Text"), [""] ) mid = TextOption(_("Middle Text"), [""])
mid.set_help(_("Text to display in the middle")) mid.set_help(_("Text to display in the middle"))
menu.add_option(category_name, "mid", mid) menu.add_option(category_name, "mid", mid)
bot = TextOption(_("Final Text"), [""] ) bot = TextOption(_("Final Text"), [""])
bot.set_help(_("Text to display last.")) bot.set_help(_("Text to display last."))
menu.add_option(category_name, "bot", bot) menu.add_option(category_name, "bot", bot)
def make_default_style(self,default_style): def make_default_style(self, default_style):
"""Make the default output style for the Custom Text report.""" """Make the default output style for the Custom Text report."""
font = FontStyle() font = FontStyle()
font.set(face=FONT_SANS_SERIF, size=12, bold=0, italic=0) font.set(face=FONT_SANS_SERIF, size=12, bold=0, italic=0)
@@ -145,7 +148,8 @@ class CustomTextOptions(MenuReportOptions):
para.set_font(font) para.set_font(font)
para.set_alignment(PARA_ALIGN_CENTER) para.set_alignment(PARA_ALIGN_CENTER)
para.set(pad=0.5) para.set(pad=0.5)
para.set_description(_('The style used for the first portion of the custom text.')) para.set_description(
_('The style used for the first portion of the custom text.'))
default_style.add_paragraph_style("CBT-Initial", para) default_style.add_paragraph_style("CBT-Initial", para)
font = FontStyle() font = FontStyle()
@@ -154,7 +158,8 @@ class CustomTextOptions(MenuReportOptions):
para.set_font(font) para.set_font(font)
para.set(pad=0.5) para.set(pad=0.5)
para.set_alignment(PARA_ALIGN_CENTER) para.set_alignment(PARA_ALIGN_CENTER)
para.set_description(_('The style used for the middle portion of the custom text.')) para.set_description(
_('The style used for the middle portion of the custom text.'))
default_style.add_paragraph_style("CBT-Middle", para) default_style.add_paragraph_style("CBT-Middle", para)
font = FontStyle() font = FontStyle()
@@ -163,5 +168,6 @@ class CustomTextOptions(MenuReportOptions):
para.set_font(font) para.set_font(font)
para.set_alignment(PARA_ALIGN_CENTER) para.set_alignment(PARA_ALIGN_CENTER)
para.set(pad=0.5) para.set(pad=0.5)
para.set_description(_('The style used for the last portion of the custom text.')) para.set_description(
_('The style used for the last portion of the custom text.'))
default_style.add_paragraph_style("CBT-Final", para) default_style.add_paragraph_style("CBT-Final", para)

View File

@@ -45,7 +45,6 @@ from gramps.gen.plug.report import Report
from gramps.gen.plug.report import utils as ReportUtils from gramps.gen.plug.report import utils as ReportUtils
from gramps.gen.plug.report import MenuReportOptions from gramps.gen.plug.report import MenuReportOptions
from gramps.gen.plug.report import stdoptions from gramps.gen.plug.report import stdoptions
from gramps.gen.datehandler import get_date
from gramps.gen.proxy import CacheProxyDb from gramps.gen.proxy import CacheProxyDb
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@@ -54,6 +53,7 @@ from gramps.gen.proxy import CacheProxyDb
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class EndOfLineReport(Report): class EndOfLineReport(Report):
""" EndOfLine Report """
def __init__(self, database, options, user): def __init__(self, database, options, user):
""" """
@@ -85,8 +85,8 @@ class EndOfLineReport(Report):
pid = menu.get_option_by_name('pid').get_value() pid = menu.get_option_by_name('pid').get_value()
self.center_person = self.database.get_person_from_gramps_id(pid) self.center_person = self.database.get_person_from_gramps_id(pid)
if (self.center_person == None) : if self.center_person is None:
raise ReportError(_("Person %s is not in the Database") % pid ) raise ReportError(_("Person %s is not in the Database") % pid)
stdoptions.run_name_format_option(self, menu) stdoptions.run_name_format_option(self, menu)
@@ -143,7 +143,7 @@ class EndOfLineReport(Report):
self.eol_map[gen] = {} self.eol_map[gen] = {}
if person_handle not in self.eol_map[gen]: if person_handle not in self.eol_map[gen]:
self.eol_map[gen][person_handle] = [] self.eol_map[gen][person_handle] = []
self.eol_map[gen][person_handle].append( new_pedigree ) self.eol_map[gen][person_handle].append(new_pedigree)
def write_report(self): def write_report(self):
""" """
@@ -166,7 +166,7 @@ class EndOfLineReport(Report):
self.doc.write_text(title) self.doc.write_text(title)
self.doc.end_paragraph() self.doc.end_paragraph()
self.doc.start_table('EolTable','EOL-Table') self.doc.start_table('EolTable', 'EOL-Table')
for generation, handles in self.eol_map.items(): for generation, handles in self.eol_map.items():
self.write_generation_row(generation) self.write_generation_row(generation)
for person_handle, pedigrees in handles.items(): for person_handle, pedigrees in handles.items():
@@ -206,9 +206,9 @@ class EndOfLineReport(Report):
death_date = self._get_date(event.get_date_object()) death_date = self._get_date(event.get_date_object())
dates = '' dates = ''
if birth_date or death_date: if birth_date or death_date:
dates = self._(" (%(birth_date)s - %(death_date)s)") % { dates = self._(" (%(birth_date)s - %(death_date)s)"
'birth_date' : birth_date, % {'birth_date' : birth_date,
'death_date' : death_date } 'death_date' : death_date})
self.doc.start_row() self.doc.start_row()
self.doc.start_cell('EOL-TableCell', 2) self.doc.start_cell('EOL-TableCell', 2)
@@ -274,54 +274,55 @@ class EndOfLineOptions(MenuReportOptions):
def make_default_style(self, default_style): def make_default_style(self, default_style):
"""Make the default output style for the End of Line Report.""" """Make the default output style for the End of Line Report."""
# Paragraph Styles # Paragraph Styles
f = FontStyle() font = FontStyle()
f.set_size(16) font.set_size(16)
f.set_type_face(FONT_SANS_SERIF) font.set_type_face(FONT_SANS_SERIF)
f.set_bold(1) font.set_bold(1)
p = ParagraphStyle() para = ParagraphStyle()
p.set_header_level(1) para.set_header_level(1)
p.set_bottom_border(1) para.set_bottom_border(1)
p.set_bottom_margin(ReportUtils.pt2cm(8)) para.set_bottom_margin(ReportUtils.pt2cm(8))
p.set_font(f) para.set_font(font)
p.set_alignment(PARA_ALIGN_CENTER) para.set_alignment(PARA_ALIGN_CENTER)
p.set_description(_("The style used for the title of the page.")) para.set_description(_("The style used for the title of the page."))
default_style.add_paragraph_style("EOL-Title", p) default_style.add_paragraph_style("EOL-Title", para)
font = FontStyle() font = FontStyle()
font.set(face=FONT_SANS_SERIF, size=12, italic=1) font.set(face=FONT_SANS_SERIF, size=12, italic=1)
p = ParagraphStyle() para = ParagraphStyle()
p.set_bottom_margin(ReportUtils.pt2cm(6)) para.set_bottom_margin(ReportUtils.pt2cm(6))
p.set_font(font) para.set_font(font)
p.set_alignment(PARA_ALIGN_CENTER) para.set_alignment(PARA_ALIGN_CENTER)
p.set_description(_('The style used for the section headers.')) para.set_description(_('The style used for the section headers.'))
default_style.add_paragraph_style("EOL-Subtitle", p) default_style.add_paragraph_style("EOL-Subtitle", para)
font = FontStyle() font = FontStyle()
font.set_size(10) font.set_size(10)
p = ParagraphStyle() para = ParagraphStyle()
p.set_font(font) para.set_font(font)
p.set_top_margin(ReportUtils.pt2cm(6)) para.set_top_margin(ReportUtils.pt2cm(6))
p.set_bottom_margin(ReportUtils.pt2cm(6)) para.set_bottom_margin(ReportUtils.pt2cm(6))
p.set_description(_('The basic style used for the text display.')) para.set_description(_('The basic style used for the text display.'))
default_style.add_paragraph_style("EOL-Normal", p) default_style.add_paragraph_style("EOL-Normal", para)
font = FontStyle() font = FontStyle()
font.set_size(12) font.set_size(12)
font.set_italic(True) font.set_italic(True)
p = ParagraphStyle() para = ParagraphStyle()
p.set_font(font) para.set_font(font)
p.set_top_margin(ReportUtils.pt2cm(6)) para.set_top_margin(ReportUtils.pt2cm(6))
p.set_description(_('The basic style used for generation headings.')) para.set_description(
default_style.add_paragraph_style("EOL-Generation", p) _('The basic style used for generation headings.'))
default_style.add_paragraph_style("EOL-Generation", para)
font = FontStyle() font = FontStyle()
font.set_size(8) font.set_size(8)
p = ParagraphStyle() para = ParagraphStyle()
p.set_font(font) para.set_font(font)
p.set_top_margin(0) para.set_top_margin(0)
p.set_bottom_margin(ReportUtils.pt2cm(6)) para.set_bottom_margin(ReportUtils.pt2cm(6))
p.set_description(_('The basic style used for the text display.')) para.set_description(_('The basic style used for the text display.'))
default_style.add_paragraph_style("EOL-Pedigree", p) default_style.add_paragraph_style("EOL-Pedigree", para)
#Table Styles #Table Styles
cell = TableCellStyle() cell = TableCellStyle()

View File

@@ -57,6 +57,7 @@ from gramps.gen.proxy import CacheProxyDb
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class FamilyGroup(Report): class FamilyGroup(Report):
""" Family Group Report """
def __init__(self, database, options, user): def __init__(self, database, options, user):
""" """
@@ -74,7 +75,7 @@ class FamilyGroup(Report):
filter - Filter to be applied to the families of the database. filter - Filter to be applied to the families of the database.
The option class carries its number, and the function The option class carries its number, and the function
returning the list of filters. returning the list of filters.
includeAttrs - Whether to include attributes incattrs - Whether to include attributes
name_format - Preferred format to display names name_format - Preferred format to display names
incl_private - Whether to include private data incl_private - Whether to include private data
living_people - How to handle living people living_people - How to handle living people
@@ -96,20 +97,20 @@ class FamilyGroup(Report):
self.filter = menu.get_option_by_name('filter').get_filter() self.filter = menu.get_option_by_name('filter').get_filter()
get_option_by_name = menu.get_option_by_name get_option_by_name = menu.get_option_by_name
get_value = lambda name:get_option_by_name(name).get_value() get_value = lambda name: get_option_by_name(name).get_value()
self.gramps_ids = get_value('gramps_ids') self.gramps_ids = get_value('gramps_ids')
self.recursive = get_value('recursive') self.recursive = get_value('recursive')
self.missingInfo = get_value('missinginfo') self.missing_info = get_value('missinginfo')
self.generations = get_value('generations') self.generations = get_value('generations')
self.incFamNotes = get_value('incFamNotes') self.inc_fam_notes = get_value('incFamNotes')
self.incParEvents = get_value('incParEvents') self.inc_par_events = get_value('incParEvents')
self.incParAddr = get_value('incParAddr') self.inc_par_addr = get_value('incParAddr')
self.incParNotes = get_value('incParNotes') self.inc_par_notes = get_value('incParNotes')
self.incParNames = get_value('incParNames') self.inc_par_names = get_value('incParNames')
self.incParMar = get_value('incParMar') self.inc_par_mar = get_value('incParMar')
self.incRelDates = get_value('incRelDates') self.inc_rel_dates = get_value('incRelDates')
self.incChiMar = get_value('incChiMar') self.inc_chi_mar = get_value('incChiMar')
self.includeAttrs = get_value('incattrs') self.include_attrs = get_value('incattrs')
stdoptions.run_name_format_option(self, menu) stdoptions.run_name_format_option(self, menu)
@@ -124,16 +125,16 @@ class FamilyGroup(Report):
place = '' place = ''
descr = event.get_description() descr = event.get_description()
if self.includeAttrs: if self.include_attrs:
for attr in event.get_attribute_list(): for attr in event.get_attribute_list():
if descr: if descr:
# translators: needed for Arabic, ignore otherwise # translators: needed for Arabic, ignore otherwise
descr += self._("; ") descr += self._("; ")
attr_type = self._get_type(attr.get_type()) attr_type = self._get_type(attr.get_type())
# translators: needed for French, ignore otherwise # translators: needed for French, ignore otherwise
descr += self._("%(str1)s: %(str2)s") % { descr += self._("%(str1)s: %(str2)s"
'str1' : self._(attr_type), % {'str1' : self._(attr_type),
'str2' : attr.get_value() } 'str2' : attr.get_value()})
self.doc.start_row() self.doc.start_row()
self.doc.start_cell("FGR-TextContents") self.doc.start_cell("FGR-TextContents")
@@ -184,7 +185,7 @@ class FamilyGroup(Report):
gid = father.get_gramps_id() gid = father.get_gramps_id()
if gid: if gid:
father_name += " (%s)" % gid father_name += " (%s)" % gid
if self.incRelDates: if self.inc_rel_dates:
birth_ref = father.get_birth_ref() birth_ref = father.get_birth_ref()
birth = " " birth = " "
if birth_ref: if birth_ref:
@@ -205,7 +206,7 @@ class FamilyGroup(Report):
gid = mother.get_gramps_id() gid = mother.get_gramps_id()
if gid: if gid:
mother_name += " (%s)" % gid mother_name += " (%s)" % gid
if self.incRelDates: if self.inc_rel_dates:
birth_ref = mother.get_birth_ref() birth_ref = mother.get_birth_ref()
birth = " " birth = " "
if birth_ref: if birth_ref:
@@ -233,7 +234,7 @@ class FamilyGroup(Report):
self.doc.end_paragraph() self.doc.end_paragraph()
self.doc.end_cell() self.doc.end_cell()
self.doc.end_row() self.doc.end_row()
elif self.missingInfo: elif self.missing_info:
self.dump_parent_line(self._("Father"), "") self.dump_parent_line(self._("Father"), "")
if mother_name != "": if mother_name != "":
@@ -250,7 +251,7 @@ class FamilyGroup(Report):
self.doc.end_paragraph() self.doc.end_paragraph()
self.doc.end_cell() self.doc.end_cell()
self.doc.end_row() self.doc.end_row()
elif self.missingInfo: elif self.missing_info:
self.dump_parent_line(self._("Mother"), "") self.dump_parent_line(self._("Mother"), "")
def dump_parent_line(self, name, text): def dump_parent_line(self, name, text):
@@ -275,17 +276,15 @@ class FamilyGroup(Report):
self.doc.end_paragraph() self.doc.end_paragraph()
self.doc.end_cell() self.doc.end_cell()
self.doc.start_cell("FGR-TextContentsEnd", 2) self.doc.start_cell("FGR-TextContentsEnd", 2)
self.doc.write_styled_note(note.get_styledtext(), self.doc.write_styled_note(
note.get_format(), 'FGR-Note', note.get_styledtext(), note.get_format(), 'FGR-Note',
contains_html= contains_html=(note.get_type() == NoteType.HTML_CODE))
(note.get_type()==NoteType.HTML_CODE)
)
self.doc.end_cell() self.doc.end_cell()
self.doc.end_row() self.doc.end_row()
def dump_parent(self, title, person_handle): def dump_parent(self, title, person_handle):
if not person_handle and not self.missingInfo: if not person_handle and not self.missing_info:
return return
elif not person_handle: elif not person_handle:
person = Person() person = Person()
@@ -299,9 +298,9 @@ class FamilyGroup(Report):
self.doc.start_paragraph('FGR-ParentName') self.doc.start_paragraph('FGR-ParentName')
mark = ReportUtils.get_person_mark(self.db, person) mark = ReportUtils.get_person_mark(self.db, person)
# translators: needed for French, ignore otherwise # translators: needed for French, ignore otherwise
self.doc.write_text(self._("%(str1)s: %(str2)s") % { self.doc.write_text(self._("%(str1)s: %(str2)s"
'str1' : title, % {'str1' : title,
'str2' : name }, mark) 'str2' : name}), mark)
if self.gramps_ids: if self.gramps_ids:
gid = person.get_gramps_id() gid = person.get_gramps_id()
if gid: if gid:
@@ -312,30 +311,30 @@ class FamilyGroup(Report):
birth_ref = person.get_birth_ref() birth_ref = person.get_birth_ref()
birth = None birth = None
evtName = self._("Birth") ev_name = self._("Birth")
if birth_ref: if birth_ref:
birth = self.db.get_event_from_handle(birth_ref.ref) birth = self.db.get_event_from_handle(birth_ref.ref)
if birth or self.missingInfo: if birth or self.missing_info:
self.dump_parent_event(evtName, birth) self.dump_parent_event(ev_name, birth)
death_ref = person.get_death_ref() death_ref = person.get_death_ref()
death = None death = None
evtName = self._("Death") ev_name = self._("Death")
if death_ref: if death_ref:
death = self.db.get_event_from_handle(death_ref.ref) death = self.db.get_event_from_handle(death_ref.ref)
if death or self.missingInfo: if death or self.missing_info:
self.dump_parent_event(evtName, death) self.dump_parent_event(ev_name, death)
self.dump_parent_parents(person) self.dump_parent_parents(person)
if self.incParEvents: if self.inc_par_events:
for event_ref in person.get_primary_event_ref_list(): for event_ref in person.get_primary_event_ref_list():
if event_ref != birth_ref and event_ref != death_ref: if event_ref != birth_ref and event_ref != death_ref:
event = self.db.get_event_from_handle(event_ref.ref) event = self.db.get_event_from_handle(event_ref.ref)
event_type = self._get_type(event.get_type()) event_type = self._get_type(event.get_type())
self.dump_parent_event(self._(event_type), event) self.dump_parent_event(self._(event_type), event)
if self.incParAddr: if self.inc_par_addr:
addrlist = person.get_address_list()[:] addrlist = person.get_address_list()[:]
for addr in addrlist: for addr in addrlist:
location = ReportUtils.get_address_str(addr) location = ReportUtils.get_address_str(addr)
@@ -359,17 +358,17 @@ class FamilyGroup(Report):
self.doc.end_cell() self.doc.end_cell()
self.doc.end_row() self.doc.end_row()
if self.incParNotes: if self.inc_par_notes:
for notehandle in person.get_note_list(): for notehandle in person.get_note_list():
note = self.db.get_note_from_handle(notehandle) note = self.db.get_note_from_handle(notehandle)
self.dump_parent_noteline(self._("Note"), note) self.dump_parent_noteline(self._("Note"), note)
if self.includeAttrs: if self.include_attrs:
for attr in person.get_attribute_list(): for attr in person.get_attribute_list():
attr_type = self._get_type(attr.get_type()) attr_type = self._get_type(attr.get_type())
self.dump_parent_line(self._(attr_type), attr.get_value()) self.dump_parent_line(self._(attr_type), attr.get_value())
if self.incParNames: if self.inc_par_names:
for alt_name in person.get_alternate_names(): for alt_name in person.get_alternate_names():
name_type = self._get_type(alt_name.get_type()) name_type = self._get_type(alt_name.get_type())
name = self._name_display.display_name(alt_name) name = self._name_display.display_name(alt_name)
@@ -387,13 +386,13 @@ class FamilyGroup(Report):
for event_ref in family_list: for event_ref in family_list:
if event_ref: if event_ref:
event = self.db.get_event_from_handle(event_ref.ref) event = self.db.get_event_from_handle(event_ref.ref)
if event.get_type() == EventType.MARRIAGE and \ if (event.get_type() == EventType.MARRIAGE and
(event_ref.get_role() == EventRoleType.FAMILY or (event_ref.get_role() == EventRoleType.FAMILY or
event_ref.get_role() == EventRoleType.PRIMARY): event_ref.get_role() == EventRoleType.PRIMARY)):
mrg = event mrg = event
break break
if len(family_list) > 0 or self.missingInfo or self.includeAttrs: if len(family_list) > 0 or self.missing_info or self.include_attrs:
self.doc.start_table("MarriageInfo", 'FGR-ParentTable') self.doc.start_table("MarriageInfo", 'FGR-ParentTable')
self.doc.start_row() self.doc.start_row()
self.doc.start_cell('FGR-ParentHead', 3) self.doc.start_cell('FGR-ParentHead', 3)
@@ -416,12 +415,12 @@ class FamilyGroup(Report):
event_type = self._get_type(event.get_type()) event_type = self._get_type(event.get_type())
self.dump_parent_event(self._(event_type), event) self.dump_parent_event(self._(event_type), event)
if self.includeAttrs: if self.include_attrs:
for attr in family.get_attribute_list(): for attr in family.get_attribute_list():
attr_type = self._get_type(attr.get_type()) attr_type = self._get_type(attr.get_type())
self.dump_parent_line(self._(attr_type), attr.get_value()) self.dump_parent_line(self._(attr_type), attr.get_value())
if self.incFamNotes: if self.inc_fam_notes:
for notehandle in family.get_note_list(): for notehandle in family.get_note_list():
note = self.database.get_note_from_handle(notehandle) note = self.database.get_note_from_handle(notehandle)
self.dump_parent_noteline(self._("Note"), note) self.dump_parent_noteline(self._("Note"), note)
@@ -476,8 +475,8 @@ class FamilyGroup(Report):
else: else:
death = None death = None
spouse_count = 0; spouse_count = 0
if self.incChiMar: if self.inc_chi_mar:
for family_handle in person.get_family_handle_list(): for family_handle in person.get_family_handle_list():
family = self.db.get_family_from_handle(family_handle) family = self.db.get_family_from_handle(family_handle)
spouse_id = None spouse_id = None
@@ -489,9 +488,10 @@ class FamilyGroup(Report):
spouse_count += 1 spouse_count += 1
self.doc.start_row() self.doc.start_row()
if (spouse_count != 0 or self.missingInfo if (spouse_count != 0
or death is not None or self.missing_info
or birth is not None): or death is not None
or birth is not None):
self.doc.start_cell('FGR-TextChild1') self.doc.start_cell('FGR-TextChild1')
else: else:
self.doc.start_cell('FGR-TextChild2') self.doc.start_cell('FGR-TextChild2')
@@ -517,19 +517,19 @@ class FamilyGroup(Report):
self.doc.end_cell() self.doc.end_cell()
self.doc.end_row() self.doc.end_row()
if self.missingInfo or birth is not None: if self.missing_info or birth is not None:
if spouse_count != 0 or self.missingInfo or death is not None: if spouse_count != 0 or self.missing_info or death is not None:
self.dump_child_event('FGR-TextChild1', self._('Birth'), birth) self.dump_child_event('FGR-TextChild1', self._('Birth'), birth)
else: else:
self.dump_child_event('FGR-TextChild2', self._('Birth'), birth) self.dump_child_event('FGR-TextChild2', self._('Birth'), birth)
if self.missingInfo or death is not None: if self.missing_info or death is not None:
if spouse_count == 0 or not self.incChiMar: if spouse_count == 0 or not self.inc_chi_mar:
self.dump_child_event('FGR-TextChild2', self._('Death'), death) self.dump_child_event('FGR-TextChild2', self._('Death'), death)
else: else:
self.dump_child_event('FGR-TextChild1', self._('Death'), death) self.dump_child_event('FGR-TextChild1', self._('Death'), death)
if self.incChiMar: if self.inc_chi_mar:
index = 0 index = 0
for family_handle in person.get_family_handle_list(): for family_handle in person.get_family_handle_list():
mrg = None mrg = None
@@ -573,7 +573,7 @@ class FamilyGroup(Report):
gid = spouse.get_gramps_id() gid = spouse.get_gramps_id()
if gid: if gid:
spouse_name += " (%s)" % gid spouse_name += " (%s)" % gid
if self.incRelDates: if self.inc_rel_dates:
birth = " " birth = " "
birth_ref = spouse.get_birth_ref() birth_ref = spouse.get_birth_ref()
if birth_ref: if birth_ref:
@@ -597,11 +597,11 @@ class FamilyGroup(Report):
self.doc.end_row() self.doc.end_row()
if mrg: if mrg:
evtName = self._("Marriage") ev_name = self._("Marriage")
if index == families: if index == families:
self.dump_child_event('FGR-TextChild2', evtName, mrg) self.dump_child_event('FGR-TextChild2', ev_name, mrg)
else: else:
self.dump_child_event('FGR-TextChild1', evtName, mrg) self.dump_child_event('FGR-TextChild1', ev_name, mrg)
def dump_family(self, family_handle, generation): def dump_family(self, family_handle, generation):
self.doc.start_paragraph('FGR-Title') self.doc.start_paragraph('FGR-Title')
@@ -619,7 +619,7 @@ class FamilyGroup(Report):
self.doc.start_paragraph("FGR-blank") self.doc.start_paragraph("FGR-blank")
self.doc.end_paragraph() self.doc.end_paragraph()
if self.incParMar: if self.inc_par_mar:
self.dump_marriage(family) self.dump_marriage(family)
self.doc.start_paragraph("FGR-blank") self.doc.start_paragraph("FGR-blank")
self.doc.end_paragraph() self.doc.end_paragraph()
@@ -690,6 +690,7 @@ class FamilyGroupOptions(MenuReportOptions):
self.__fid = None self.__fid = None
self.__filter = None self.__filter = None
self.__recursive = None self.__recursive = None
self._nf = None
MenuReportOptions.__init__(self, name, dbase) MenuReportOptions.__init__(self, name, dbase)
def add_menu_options(self, menu): def add_menu_options(self, menu):
@@ -740,45 +741,45 @@ class FamilyGroupOptions(MenuReportOptions):
"report (recursive only).")) "report (recursive only)."))
add_option("generations", generations) add_option("generations", generations)
incParEvents = BooleanOption(_("Parent Events"), False) inc_par_events = BooleanOption(_("Parent Events"), False)
incParEvents.set_help(_("Whether to include events for parents.")) inc_par_events.set_help(_("Whether to include events for parents."))
add_option("incParEvents", incParEvents) add_option("incParEvents", inc_par_events)
incParAddr = BooleanOption(_("Parent Addresses"), False) inc_par_addr = BooleanOption(_("Parent Addresses"), False)
incParAddr.set_help(_("Whether to include addresses for parents.")) inc_par_addr.set_help(_("Whether to include addresses for parents."))
add_option("incParAddr", incParAddr) add_option("incParAddr", inc_par_addr)
incParNotes = BooleanOption(_("Parent Notes"), False) inc_par_notes = BooleanOption(_("Parent Notes"), False)
incParNotes.set_help(_("Whether to include notes for parents.")) inc_par_notes.set_help(_("Whether to include notes for parents."))
add_option("incParNotes", incParNotes) add_option("incParNotes", inc_par_notes)
incattrs = BooleanOption(_("Parent Attributes"), False) incattrs = BooleanOption(_("Parent Attributes"), False)
incattrs.set_help(_("Whether to include attributes.")) incattrs.set_help(_("Whether to include attributes."))
add_option("incattrs", incattrs) add_option("incattrs", incattrs)
incParNames = BooleanOption(_("Alternate Parent Names"), False) inc_par_names = BooleanOption(_("Alternate Parent Names"), False)
incParNames.set_help(_("Whether to include alternate " inc_par_names.set_help(
"names for parents.")) _("Whether to include alternate names for parents."))
add_option("incParNames", incParNames) add_option("incParNames", inc_par_names)
incParMar = BooleanOption(_("Parent Marriage"), True) inc_par_mar = BooleanOption(_("Parent Marriage"), True)
incParMar.set_help(_("Whether to include marriage information " inc_par_mar.set_help(
"for parents.")) _("Whether to include marriage information for parents."))
add_option("incParMar", incParMar) add_option("incParMar", inc_par_mar)
incFamNotes = BooleanOption(_("Family Notes"), False) inc_fam_notes = BooleanOption(_("Family Notes"), False)
incFamNotes.set_help(_("Whether to include notes for families.")) inc_fam_notes.set_help(_("Whether to include notes for families."))
add_option("incFamNotes", incFamNotes) add_option("incFamNotes", inc_fam_notes)
incRelDates = BooleanOption(_("Dates of Relatives"), False) inc_rel_dates = BooleanOption(_("Dates of Relatives"), False)
incRelDates.set_help(_("Whether to include dates for relatives " inc_rel_dates.set_help(_("Whether to include dates for relatives "
"(father, mother, spouse).")) "(father, mother, spouse)."))
add_option("incRelDates", incRelDates) add_option("incRelDates", inc_rel_dates)
incChiMar = BooleanOption(_("Children Marriages"), True) inc_chi_mar = BooleanOption(_("Children Marriages"), True)
incChiMar.set_help(_("Whether to include marriage information " inc_chi_mar.set_help(
"for children.")) _("Whether to include marriage information for children."))
add_option("incChiMar", incChiMar) add_option("incChiMar", inc_chi_mar)
########################## ##########################
add_option = partial(menu.add_option, _("Missing Information")) add_option = partial(menu.add_option, _("Missing Information"))
@@ -812,6 +813,7 @@ class FamilyGroupOptions(MenuReportOptions):
self.__fid.set_available(True) self.__fid.set_available(True)
else: # filters that don't else: # filters that don't
self.__fid.set_available(False) self.__fid.set_available(False)
# only allow recursion if the center family is the only family # only allow recursion if the center family is the only family
if self.__recursive and filter_value == 0: if self.__recursive and filter_value == 0:
self.__recursive.set_available(True) self.__recursive.set_available(True)

View File

@@ -56,6 +56,7 @@ from gramps.gen.proxy import CacheProxyDb
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class KinshipReport(Report): class KinshipReport(Report):
""" Kinship Report """
def __init__(self, database, options, user): def __init__(self, database, options, user):
""" """
@@ -93,14 +94,14 @@ class KinshipReport(Report):
self.__db = self.database self.__db = self.database
self.max_descend = menu.get_option_by_name('maxdescend').get_value() self.max_descend = menu.get_option_by_name('maxdescend').get_value()
self.max_ascend = menu.get_option_by_name('maxascend').get_value() self.max_ascend = menu.get_option_by_name('maxascend').get_value()
self.inc_spouses = menu.get_option_by_name('incspouses').get_value() self.inc_spouses = menu.get_option_by_name('incspouses').get_value()
self.inc_cousins = menu.get_option_by_name('inccousins').get_value() self.inc_cousins = menu.get_option_by_name('inccousins').get_value()
self.inc_aunts = menu.get_option_by_name('incaunts').get_value() self.inc_aunts = menu.get_option_by_name('incaunts').get_value()
pid = menu.get_option_by_name('pid').get_value() pid = menu.get_option_by_name('pid').get_value()
self.person = self.database.get_person_from_gramps_id(pid) self.person = self.database.get_person_from_gramps_id(pid)
if self.person is None: if self.person is None:
raise ReportError(_("Person %s is not in the Database") % pid ) raise ReportError(_("Person %s is not in the Database") % pid)
stdoptions.run_name_format_option(self, menu) stdoptions.run_name_format_option(self, menu)
@@ -140,12 +141,12 @@ class KinshipReport(Report):
for Gb in Gbs: for Gb in Gbs:
# To understand these calculations, see: # To understand these calculations, see:
# http://en.wikipedia.org/wiki/Cousin#Mathematical_definitions # http://en.wikipedia.org/wiki/Cousin#Mathematical_definitions
x = min (Ga, Gb) _x_ = min(Ga, Gb)
y = abs(Ga-Gb) _y_ = abs(Ga - Gb)
# Skip unrequested people # Skip unrequested people
if x == 1 and y > 0 and not self.inc_aunts: if _x_ == 1 and _y_ > 0 and not self.inc_aunts:
continue continue
elif x > 1 and not self.inc_cousins: elif _x_ > 1 and not self.inc_cousins:
continue continue
get_rel_str = self.rel_calc.get_plural_relationship_string get_rel_str = self.rel_calc.get_plural_relationship_string
@@ -154,8 +155,8 @@ class KinshipReport(Report):
self.write_people(self._(title), self.kinship_map[Ga][Gb]) self.write_people(self._(title), self.kinship_map[Ga][Gb])
if (self.inc_spouses and if (self.inc_spouses and
Ga in self.spouse_map and Ga in self.spouse_map and
Gb in self.spouse_map[Ga]): Gb in self.spouse_map[Ga]):
title = get_rel_str(Ga, Gb, in_law_b=True) title = get_rel_str(Ga, Gb, in_law_b=True)
self.write_people(self._(title), self.spouse_map[Ga][Gb]) self.write_people(self._(title), self.spouse_map[Ga][Gb])
@@ -315,9 +316,9 @@ class KinshipReport(Report):
death_date = self._get_date(death.get_date_object()) death_date = self._get_date(death.get_date_object())
dates = '' dates = ''
if birth_date or death_date: if birth_date or death_date:
dates = self._(" (%(birth_date)s - %(death_date)s)") % { dates = self._(" (%(birth_date)s - %(death_date)s)"
'birth_date' : birth_date, % {'birth_date' : birth_date,
'death_date' : death_date } 'death_date' : death_date})
self.doc.start_paragraph('KIN-Normal') self.doc.start_paragraph('KIN-Normal')
self.doc.write_text(name, mark) self.doc.write_text(name, mark)
@@ -378,33 +379,33 @@ class KinshipOptions(MenuReportOptions):
def make_default_style(self, default_style): def make_default_style(self, default_style):
"""Make the default output style for the Kinship Report.""" """Make the default output style for the Kinship Report."""
f = FontStyle() font = FontStyle()
f.set_size(16) font.set_size(16)
f.set_type_face(FONT_SANS_SERIF) font.set_type_face(FONT_SANS_SERIF)
f.set_bold(1) font.set_bold(1)
p = ParagraphStyle() para = ParagraphStyle()
p.set_header_level(1) para.set_header_level(1)
p.set_bottom_border(1) para.set_bottom_border(1)
p.set_bottom_margin(ReportUtils.pt2cm(8)) para.set_bottom_margin(ReportUtils.pt2cm(8))
p.set_font(f) para.set_font(font)
p.set_alignment(PARA_ALIGN_CENTER) para.set_alignment(PARA_ALIGN_CENTER)
p.set_description(_("The style used for the title of the page.")) para.set_description(_("The style used for the title of the page."))
default_style.add_paragraph_style("KIN-Title", p) default_style.add_paragraph_style("KIN-Title", para)
font = FontStyle() font = FontStyle()
font.set_size(12) font.set_size(12)
font.set_bold(True) font.set_bold(True)
p = ParagraphStyle() para = ParagraphStyle()
p.set_header_level(3) para.set_header_level(3)
p.set_font(font) para.set_font(font)
p.set_top_margin(ReportUtils.pt2cm(6)) para.set_top_margin(ReportUtils.pt2cm(6))
p.set_description(_('The basic style used for sub-headings.')) para.set_description(_('The basic style used for sub-headings.'))
default_style.add_paragraph_style("KIN-Subtitle", p) default_style.add_paragraph_style("KIN-Subtitle", para)
font = FontStyle() font = FontStyle()
font.set_size(10) font.set_size(10)
p = ParagraphStyle() para = ParagraphStyle()
p.set_font(font) para.set_font(font)
p.set_left_margin(0.5) para.set_left_margin(0.5)
p.set_description(_('The basic style used for the text display.')) para.set_description(_('The basic style used for the text display.'))
default_style.add_paragraph_style("KIN-Normal", p) default_style.add_paragraph_style("KIN-Normal", para)

View File

@@ -79,8 +79,8 @@ class NumberOfAncestorsReport(Report):
pid = options.menu.get_option_by_name('pid').get_value() pid = options.menu.get_option_by_name('pid').get_value()
self.__person = self.__db.get_person_from_gramps_id(pid) self.__person = self.__db.get_person_from_gramps_id(pid)
if (self.__person == None) : if self.__person is None:
raise ReportError(_("Person %s is not in the Database") % pid ) raise ReportError(_("Person %s is not in the Database") % pid)
lang = options.menu.get_option_by_name('trans').get_value() lang = options.menu.get_option_by_name('trans').get_value()
self._locale = self.set_locale(lang) self._locale = self.set_locale(lang)
@@ -95,7 +95,7 @@ class NumberOfAncestorsReport(Report):
thisgen = {} thisgen = {}
all_people = {} all_people = {}
total_theoretical = 0 total_theoretical = 0
thisgen[self.__person.get_handle()]=1 thisgen[self.__person.get_handle()] = 1
ngettext = self._locale.translation.ngettext # to see "nearby" comments ngettext = self._locale.translation.ngettext # to see "nearby" comments
self.doc.start_paragraph("NOA-Title") self.doc.start_paragraph("NOA-Title")
@@ -113,10 +113,10 @@ class NumberOfAncestorsReport(Report):
if thisgen != {}: if thisgen != {}:
thisgensize = len(thisgen) thisgensize = len(thisgen)
gen += 1 gen += 1
theoretical = math.pow(2, ( gen - 1 ) ) theoretical = math.pow(2, (gen - 1))
total_theoretical += theoretical total_theoretical += theoretical
percent = '(%s%%)' % self._locale.format('%3.2f', percent = '(%s%%)' % self._locale.format(
((sum(thisgen.values()) / theoretical ) * 100)) '%3.2f', ((sum(thisgen.values()) / theoretical) * 100))
# TC # English return something like: # TC # English return something like:
# Generation 3 has 2 individuals. (50.00%) # Generation 3 has 2 individuals. (50.00%)
@@ -156,21 +156,20 @@ class NumberOfAncestorsReport(Report):
all_people.get(mother_handle, 0) + person_data all_people.get(mother_handle, 0) + person_data
) )
if( total_theoretical != 1 ): if total_theoretical != 1:
percent = '(%3.2f%%)' % (( sum(all_people.values()) percent = '(%3.2f%%)' % (
/ (total_theoretical-1) ) * 100) (sum(all_people.values()) / (total_theoretical-1)) * 100)
else: else:
percent = 0 percent = 0
# TC # English return something like: # TC # English return something like:
# Total ancestors in generations 2 to 3 is 4. (66.67%) # Total ancestors in generations 2 to 3 is 4. (66.67%)
text = self._("Total ancestors in generations %(second_generation)d to " text = self._("Total ancestors in generations %(second_generation)d "
"%(last_generation)d is %(count)d. %(percent)s") % { "to %(last_generation)d is %(count)d. %(percent)s") % {
'second_generation': 2, 'second_generation': 2,
'last_generation' : gen, 'last_generation' : gen,
'count' : len(all_people), 'count' : len(all_people),
'percent' : percent 'percent' : percent}
}
self.doc.start_paragraph('NOA-Normal') self.doc.start_paragraph('NOA-Normal')
self.doc.write_text(text) self.doc.write_text(text)

View File

@@ -37,7 +37,7 @@
from gramps.gen.const import GRAMPS_LOCALE as glocale from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext _ = glocale.translation.sgettext
from gramps.gen.plug.menu import (FilterOption, PlaceListOption, from gramps.gen.plug.menu import (FilterOption, PlaceListOption,
EnumeratedListOption, BooleanOption) EnumeratedListOption)
from gramps.gen.plug.report import Report from gramps.gen.plug.report import Report
from gramps.gen.plug.report import MenuReportOptions from gramps.gen.plug.report import MenuReportOptions
from gramps.gen.plug.report import stdoptions from gramps.gen.plug.report import stdoptions
@@ -48,7 +48,6 @@ from gramps.gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle,
from gramps.gen.sort import Sort from gramps.gen.sort import Sort
from gramps.gen.utils.location import get_location_list from gramps.gen.utils.location import get_location_list
from gramps.gen.display.place import displayer as place_displayer from gramps.gen.display.place import displayer as place_displayer
from gramps.gen.lib import PlaceType
from gramps.gen.errors import ReportError from gramps.gen.errors import ReportError
from gramps.gen.proxy import LivingProxyDb, CacheProxyDb from gramps.gen.proxy import LivingProxyDb, CacheProxyDb
@@ -88,17 +87,18 @@ class PlaceReport(Report):
stdoptions.run_private_data_option(self, menu) stdoptions.run_private_data_option(self, menu)
living_opt = stdoptions.run_living_people_option(self, menu, rlocale) living_opt = stdoptions.run_living_people_option(self, menu, rlocale)
self.database = CacheProxyDb(self.database) self.database = CacheProxyDb(self.database)
self._db = self.database
self._lv = menu.get_option_by_name('living_people').get_value() self._lv = menu.get_option_by_name('living_people').get_value()
for (value, description) in living_opt.get_items(xml_items=True): for (value, description) in living_opt.get_items(xml_items=True):
if value == self._lv: if value == self._lv:
living_desc = self._(description) living_desc = self._(description)
break break
self.living_desc = self._("(Living people: %(option_name)s)" self.living_desc = self._(
% {'option_name': living_desc}) "(Living people: %(option_name)s)") % {'option_name': living_desc}
places = menu.get_option_by_name('places').get_value() places = menu.get_option_by_name('places').get_value()
self.center = menu.get_option_by_name('center').get_value() self.center = menu.get_option_by_name('center').get_value()
stdoptions.run_name_format_option(self, menu) stdoptions.run_name_format_option(self, menu)
self._nd = self._name_display self._nd = self._name_display
@@ -106,20 +106,21 @@ class PlaceReport(Report):
filter_option = menu.get_option_by_name('filter') filter_option = menu.get_option_by_name('filter')
self.filter = filter_option.get_filter() self.filter = filter_option.get_filter()
self.sort = Sort(self.database) self.sort = Sort(self._db)
self.place_handles = [] self.place_handles = []
if self.filter.get_name() != '': if self.filter.get_name() != '':
# Use the selected filter to provide a list of place handles # Use the selected filter to provide a list of place handles
plist = self.database.iter_place_handles() plist = self._db.iter_place_handles()
self.place_handles = self.filter.apply(self.database, plist) self.place_handles = self.filter.apply(self._db, plist)
if places: if places:
# Add places selected individually # Add places selected individually
self.place_handles += self.__get_place_handles(places) self.place_handles += self.__get_place_handles(places)
if not self.place_handles: if not self.place_handles:
raise ReportError(_('Place Report'), raise ReportError(
_('Place Report'),
_('Please select at least one place before running this.')) _('Please select at least one place before running this.'))
self.place_handles.sort(key=self.sort.by_place_title_key) self.place_handles.sort(key=self.sort.by_place_title_key)
@@ -151,8 +152,8 @@ class PlaceReport(Report):
place_nbr = 1 place_nbr = 1
with self._user.progress(_("Place Report"), with self._user.progress(_("Place Report"),
_("Generating report"), _("Generating report"),
len(self.place_handles)) as step: len(self.place_handles)) as step:
for handle in self.place_handles: for handle in self.place_handles:
self.__write_place(handle, place_nbr) self.__write_place(handle, place_nbr)
@@ -161,7 +162,7 @@ class PlaceReport(Report):
elif self.center == "Person": elif self.center == "Person":
self.__write_referenced_persons(handle) self.__write_referenced_persons(handle)
else: else:
raise AttributeError("no such center: '%s'" % self.center) raise AttributeError("no such center: '%s'" % self.center)
place_nbr += 1 place_nbr += 1
# increment progress bar # increment progress bar
step() step()
@@ -171,13 +172,14 @@ class PlaceReport(Report):
""" """
This procedure writes out the details of a single place This procedure writes out the details of a single place
""" """
place = self.database.get_place_from_handle(handle) place = self._db.get_place_from_handle(handle)
place_details = [self._("Gramps ID: %s ") % place.get_gramps_id()] place_details = [self._("Gramps ID: %s ") % place.get_gramps_id()]
for level in get_location_list(self.database, place): for level in get_location_list(self._db, place):
place_details.append("%(type)s: %(name)s " % # translators: needed for French, ignore otherwise
{'type': self._(level[1].xml_str()), place_details.append(self._(
'name': level[0]}) "%(str1)s: %(str2)s") % {'str1': self._(level[1].xml_str()),
'str2': level[0]})
place_names = '' place_names = ''
all_names = place.get_all_names() all_names = place.get_all_names()
@@ -191,10 +193,9 @@ class PlaceReport(Report):
place_names += ' (%s)' % place_name.get_language() place_names += ' (%s)' % place_name.get_language()
place_details += [self._("places|All Names: %s") % place_names,] place_details += [self._("places|All Names: %s") % place_names,]
self.doc.start_paragraph("PLC-PlaceTitle") self.doc.start_paragraph("PLC-PlaceTitle")
place_title = place_displayer.display(self.database, place) place_title = place_displayer.display(self._db, place)
self.doc.write_text(("%(nbr)s. %(place)s") % self.doc.write_text(("%(nbr)s. %(place)s") % {'nbr' : place_nbr,
{'nbr' : place_nbr, 'place' : place_title})
'place' : place_title})
self.doc.end_paragraph() self.doc.end_paragraph()
for item in place_details: for item in place_details:
@@ -207,7 +208,7 @@ class PlaceReport(Report):
This procedure writes out each of the events related to the place This procedure writes out each of the events related to the place
""" """
event_handles = [event_handle for (object_type, event_handle) in event_handles = [event_handle for (object_type, event_handle) in
self.database.find_backlink_handles(handle, ['Event'])] self._db.find_backlink_handles(handle, ['Event'])]
event_handles.sort(key=self.sort.by_date_key) event_handles.sort(key=self.sort.by_date_key)
if event_handles: if event_handles:
@@ -228,7 +229,7 @@ class PlaceReport(Report):
self.doc.end_row() self.doc.end_row()
for evt_handle in event_handles: for evt_handle in event_handles:
event = self.database.get_event_from_handle(evt_handle) event = self._db.get_event_from_handle(evt_handle)
if event: # will be None if marked private if event: # will be None if marked private
date = self._get_date(event.get_date_object()) date = self._get_date(event.get_date_object())
descr = event.get_description() descr = event.get_description()
@@ -236,14 +237,14 @@ class PlaceReport(Report):
person_list = [] person_list = []
ref_handles = [x for x in ref_handles = [x for x in
self.database.find_backlink_handles(evt_handle)] self._db.find_backlink_handles(evt_handle)]
if not ref_handles: # since the backlink may point to private if not ref_handles: # since the backlink may point to private
continue # data, ignore an event with no backlinks continue # data, ignore an event with no backlinks
for (ref_type, ref_handle) in ref_handles: for (ref_type, ref_handle) in ref_handles:
if ref_type == 'Person': if ref_type == 'Person':
person_list.append(ref_handle) person_list.append(ref_handle)
else: else:
family = self.database.get_family_from_handle(ref_handle) family = self._db.get_family_from_handle(ref_handle)
father = family.get_father_handle() father = family.get_father_handle()
if father: if father:
person_list.append(father) person_list.append(father)
@@ -254,7 +255,7 @@ class PlaceReport(Report):
people = "" people = ""
person_list = list(set(person_list)) person_list = list(set(person_list))
for p_handle in person_list: for p_handle in person_list:
person = self.database.get_person_from_handle(p_handle) person = self._db.get_person_from_handle(p_handle)
if person: if person:
if people == "": if people == "":
people = "%(name)s (%(id)s)" \ people = "%(name)s (%(id)s)" \
@@ -285,7 +286,7 @@ class PlaceReport(Report):
This procedure writes out each of the people related to the place This procedure writes out each of the people related to the place
""" """
event_handles = [event_handle for (object_type, event_handle) in event_handles = [event_handle for (object_type, event_handle) in
self.database.find_backlink_handles(handle, ['Event'])] self._db.find_backlink_handles(handle, ['Event'])]
if event_handles: if event_handles:
self.doc.start_paragraph("PLC-Section") self.doc.start_paragraph("PLC-Section")
@@ -307,44 +308,44 @@ class PlaceReport(Report):
person_dict = {} person_dict = {}
for evt_handle in event_handles: for evt_handle in event_handles:
ref_handles = [x for x in ref_handles = [x for x in
self.database.find_backlink_handles(evt_handle)] self._db.find_backlink_handles(evt_handle)]
for (ref_type, ref_handle) in ref_handles: for (ref_type, ref_handle) in ref_handles:
if ref_type == 'Person': if ref_type == 'Person':
person = self.database.get_person_from_handle(ref_handle) person = self._db.get_person_from_handle(ref_handle)
nameEntry = "%s (%s)" % (self._nd.display(person), name_entry = "%s (%s)" % (self._nd.display(person),
person.get_gramps_id()) person.get_gramps_id())
else: else:
family = self.database.get_family_from_handle(ref_handle) family = self._db.get_family_from_handle(ref_handle)
f_handle = family.get_father_handle() f_handle = family.get_father_handle()
m_handle = family.get_mother_handle() m_handle = family.get_mother_handle()
if f_handle and m_handle: if f_handle and m_handle:
father = self.database.get_person_from_handle(f_handle) father = self._db.get_person_from_handle(f_handle)
mother = self.database.get_person_from_handle(m_handle) mother = self._db.get_person_from_handle(m_handle)
nameEntry = self._("%(father)s (%(father_id)s) and " name_entry = self._(
"%(mother)s (%(mother_id)s)") % \ "%(father)s (%(father_id)s) and "
{ 'father' : self._nd.display(father), "%(mother)s (%(mother_id)s)") % {
'father_id' : father.get_gramps_id(), 'father' : self._nd.display(father),
'mother' : self._nd.display(mother), 'father_id' : father.get_gramps_id(),
'mother_id' : mother.get_gramps_id()} 'mother' : self._nd.display(mother),
'mother_id' : mother.get_gramps_id()}
elif f_handle or m_handle: elif f_handle or m_handle:
if f_handle: if f_handle:
p_handle = f_handle p_handle = f_handle
else: else:
p_handle = m_handle p_handle = m_handle
person = self.database.get_person_from_handle(p_handle) person = self._db.get_person_from_handle(p_handle)
nameEntry = "%s (%s)" % \ name_entry = "%s (%s)" % (self._nd.display(person),
(self._nd.display(person), person.get_gramps_id())
person.get_gramps_id())
else: else:
# No parents - bug #7299 # No parents - bug #7299
continue continue
if nameEntry in person_dict: if name_entry in person_dict:
person_dict[nameEntry].append(evt_handle) person_dict[name_entry].append(evt_handle)
else: else:
person_dict[nameEntry] = [] person_dict[name_entry] = []
person_dict[nameEntry].append(evt_handle) person_dict[name_entry].append(evt_handle)
keys = list(person_dict.keys()) keys = list(person_dict.keys())
keys.sort() keys.sort()
@@ -353,7 +354,7 @@ class PlaceReport(Report):
people = entry people = entry
person_dict[entry].sort(key=self.sort.by_date_key) person_dict[entry].sort(key=self.sort.by_date_key)
for evt_handle in person_dict[entry]: for evt_handle in person_dict[entry]:
event = self.database.get_event_from_handle(evt_handle) event = self._db.get_event_from_handle(evt_handle)
if event: if event:
date = self._get_date(event.get_date_object()) date = self._get_date(event.get_date_object())
descr = event.get_description() descr = event.get_description()
@@ -382,7 +383,7 @@ class PlaceReport(Report):
""" """
place_handles = [] place_handles = []
for place_gid in places.split(): for place_gid in places.split():
place = self.database.get_place_from_gramps_id(place_gid) place = self._db.get_place_from_gramps_id(place_gid)
if place is not None: if place is not None:
#place can be None if option is gid of other fam tree #place can be None if option is gid of other fam tree
place_handles.append(place.get_handle()) place_handles.append(place.get_handle())
@@ -432,9 +433,7 @@ class PlaceOptions(MenuReportOptions):
stdoptions.add_name_format_option(menu, category_name) stdoptions.add_name_format_option(menu, category_name)
center = EnumeratedListOption(_("Center on"), "Event") center = EnumeratedListOption(_("Center on"), "Event")
center.set_items([ center.set_items([("Event", _("Event")), ("Person", _("Person"))])
("Event", _("Event")),
("Person", _("Person"))])
center.set_help(_("If report is event or person centered")) center.set_help(_("If report is event or person centered"))
menu.add_option(category_name, "center", center) menu.add_option(category_name, "center", center)

View File

@@ -21,6 +21,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
""" Records Report """
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# Standard Python modules # Standard Python modules
@@ -57,6 +59,7 @@ from gramps.gen.proxy import LivingProxyDb, CacheProxyDb
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class RecordsReport(Report): class RecordsReport(Report):
""" Records Report """
def __init__(self, database, options, user): def __init__(self, database, options, user):
""" """
@@ -84,8 +87,8 @@ class RecordsReport(Report):
if value == self._lv: if value == self._lv:
living_desc = self._(description) living_desc = self._(description)
break break
self.living_desc = self._("(Living people: %(option_name)s)" self.living_desc = self._(
% {'option_name': living_desc}) "(Living people: %(option_name)s)") % {'option_name': living_desc}
filter_option = menu.get_option_by_name('filter') filter_option = menu.get_option_by_name('filter')
self.filter = filter_option.get_filter() self.filter = filter_option.get_filter()
@@ -155,18 +158,19 @@ class RecordsReport(Report):
mom = self.database.get_person_from_handle(m_handle) mom = self.database.get_person_from_handle(m_handle)
m_mark = ReportUtils.get_person_mark(self.database, mom) m_mark = ReportUtils.get_person_mark(self.database, mom)
else: else:
raise ReportError(_("Option '%(opt_name)s' is present " raise ReportError(_(
"in %(file)s\n but is not known to " "Option '%(opt_name)s' is present "
"the module. Ignoring...") % "in %(file)s\n but is not known to "
{'opt_name': handletype, "the module. Ignoring...")
'file': 'libnarrate.py'}) % {'opt_name': handletype,
'file': 'libnarrate.py'})
# since the error is very unlikely I reused the string # since the error is very unlikely I reused the string
if value != last_value: if value != last_value:
last_value = value last_value = value
rank = number rank = number
self.doc.start_paragraph('REC-Normal') self.doc.start_paragraph('REC-Normal')
self.doc.write_text(self._("%(number)s. ") self.doc.write_text(
% {'number': rank+1}) self._("%(number)s. ") % {'number': rank+1})
self.doc.write_markup(str(name), name.get_tags(), mark) self.doc.write_markup(str(name), name.get_tags(), mark)
if handletype == 'Family': if handletype == 'Family':
self.doc.write_text('', f_mark) self.doc.write_text('', f_mark)
@@ -198,6 +202,7 @@ class RecordsReportOptions(MenuReportOptions):
self.__pid = None self.__pid = None
self.__filter = None self.__filter = None
self.__db = dbase self.__db = dbase
self._nf = None
MenuReportOptions.__init__(self, name, dbase) MenuReportOptions.__init__(self, name, dbase)
@@ -207,7 +212,7 @@ class RecordsReportOptions(MenuReportOptions):
self.__filter = FilterOption(_("Filter"), 0) self.__filter = FilterOption(_("Filter"), 0)
self.__filter.set_help( self.__filter.set_help(
_("Determines what people are included in the report.")) _("Determines what people are included in the report."))
menu.add_option(category_name, "filter", self.__filter) menu.add_option(category_name, "filter", self.__filter)
self.__filter.connect('value-changed', self.__filter_changed) self.__filter.connect('value-changed', self.__filter_changed)
@@ -232,7 +237,9 @@ class RecordsReportOptions(MenuReportOptions):
callname.set_items([ callname.set_items([
(CALLNAME_DONTUSE, _("Don't use call name")), (CALLNAME_DONTUSE, _("Don't use call name")),
(CALLNAME_REPLACE, _("Replace first names with call name")), (CALLNAME_REPLACE, _("Replace first names with call name")),
(CALLNAME_UNDERLINE_ADD, _("Underline call name in first names / add call name to first name"))]) (CALLNAME_UNDERLINE_ADD,
_("Underline call name in first names / "
"add call name to first name"))])
menu.add_option(category_name, "callname", callname) menu.add_option(category_name, "callname", callname)
footer = StringOption(_("Footer text"), "") footer = StringOption(_("Footer text"), "")

View File

@@ -20,6 +20,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# #
""" Simple Book Title for the book report """
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# python modules # python modules
@@ -49,6 +51,7 @@ from gramps.gen.plug.docgen import (FontStyle, ParagraphStyle,
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class SimpleBookTitle(Report): class SimpleBookTitle(Report):
""" This report class generates a title page for a book. """ """ This report class generates a title page for a book. """
def __init__(self, database, options, user): def __init__(self, database, options, user):
""" """
Create SimpleBookTitle object that produces the report. Create SimpleBookTitle object that produces the report.
@@ -95,11 +98,10 @@ class SimpleBookTitle(Report):
if self.image_size: if self.image_size:
image_size = self.image_size image_size = self.image_size
else: else:
image_size = min( image_size = min(0.8 * self.doc.get_usable_width(),
0.8 * self.doc.get_usable_width(), 0.7 * self.doc.get_usable_height())
0.7 * self.doc.get_usable_height() )
self.doc.add_media(filename, 'center', self.doc.add_media(filename, 'center',
image_size, image_size) image_size, image_size)
else: else:
self._user.warn(_('Could not add photo to page'), self._user.warn(_('Could not add photo to page'),
_('File %s does not exist') % filename) _('File %s does not exist') % filename)
@@ -127,24 +129,25 @@ class SimpleBookTitleOptions(MenuReportOptions):
""" Add the options for this report """ """ Add the options for this report """
category_name = _("Report Options") category_name = _("Report Options")
title = StringOption(_('book|Title'), _('Title of the Book') ) title = StringOption(_('book|Title'), _('Title of the Book'))
title.set_help(_("Title string for the book.")) title.set_help(_("Title string for the book."))
menu.add_option(category_name, "title", title) menu.add_option(category_name, "title", title)
subtitle = StringOption(_('Subtitle'), _('Subtitle of the Book') ) subtitle = StringOption(_('Subtitle'), _('Subtitle of the Book'))
subtitle.set_help(_("Subtitle string for the book.")) subtitle.set_help(_("Subtitle string for the book."))
menu.add_option(category_name, "subtitle", subtitle) menu.add_option(category_name, "subtitle", subtitle)
dateinfo = time.localtime(time.time()) dateinfo = time.localtime(time.time())
rname = self.__db.get_researcher().get_name() rname = self.__db.get_researcher().get_name()
footer_string = _('Copyright %(year)d %(name)s') % { footer_string = _('Copyright %(year)d %(name)s') % {
'year' : dateinfo[0], 'name' : rname } 'year' : dateinfo[0], 'name' : rname}
footer = StringOption(_('Footer'), footer_string ) footer = StringOption(_('Footer'), footer_string)
footer.set_help(_("Footer string for the page.")) footer.set_help(_("Footer string for the page."))
menu.add_option(category_name, "footer", footer) menu.add_option(category_name, "footer", footer)
imgid = MediaOption(_('Image')) imgid = MediaOption(_('Image'))
imgid.set_help( _("Gramps ID of the media object to use as an image.")) imgid.set_help(
_("Gramps ID of the media object to use as an image."))
menu.add_option(category_name, "imgid", imgid) menu.add_option(category_name, "imgid", imgid)
imgsize = NumberOption(_('Image Size'), 0, 0, 20, 0.1) imgsize = NumberOption(_('Image Size'), 0, 0, 20, 0.1)

View File

@@ -60,6 +60,7 @@ from gramps.gen.proxy import LivingProxyDb, CacheProxyDb
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class TagReport(Report): class TagReport(Report):
""" Tag Report """
def __init__(self, database, options, user): def __init__(self, database, options, user):
""" """
@@ -95,12 +96,13 @@ class TagReport(Report):
if value == self._lv: if value == self._lv:
living_desc = self._(description) living_desc = self._(description)
break break
self.living_desc = self._("(Living people: %(option_name)s)" self.living_desc = self._(
% {'option_name': living_desc}) "(Living people: %(option_name)s)") % {'option_name': living_desc}
self.tag = menu.get_option_by_name('tag').get_value() self.tag = menu.get_option_by_name('tag').get_value()
if not self.tag: if not self.tag:
raise ReportError(_('Tag Report'), raise ReportError(
_('Tag Report'),
_('You must first create a tag before running this report.')) _('You must first create a tag before running this report.'))
stdoptions.run_name_format_option(self, menu) stdoptions.run_name_format_option(self, menu)
@@ -128,11 +130,12 @@ class TagReport(Report):
self.write_citations() self.write_citations()
def write_people(self): def write_people(self):
""" write the people associated with the tag """
plist = self.database.iter_person_handles() plist = self.database.iter_person_handles()
FilterClass = GenericFilterFactory('Person') filter_class = GenericFilterFactory('Person')
filter = FilterClass() a_filter = filter_class()
filter.add_rule(rules.person.HasTag([self.tag])) a_filter.add_rule(rules.person.HasTag([self.tag]))
ind_list = filter.apply(self.database, plist) ind_list = a_filter.apply(self.database, plist)
if not ind_list: if not ind_list:
return return
@@ -143,7 +146,7 @@ class TagReport(Report):
self.doc.write_text(header, mark) self.doc.write_text(header, mark)
self.doc.end_paragraph() self.doc.end_paragraph()
self.doc.start_table('PeopleTable','TR-Table') self.doc.start_table('PeopleTable', 'TR-Table')
self.doc.start_row() self.doc.start_row()
@@ -197,7 +200,7 @@ class TagReport(Report):
birth_ref = person.get_birth_ref() birth_ref = person.get_birth_ref()
if birth_ref: if birth_ref:
event = self.database.get_event_from_handle(birth_ref.ref) event = self.database.get_event_from_handle(birth_ref.ref)
self.doc.write_text(get_date( event )) self.doc.write_text(get_date(event))
self.doc.end_paragraph() self.doc.end_paragraph()
self.doc.end_cell() self.doc.end_cell()
@@ -206,7 +209,7 @@ class TagReport(Report):
death_ref = person.get_death_ref() death_ref = person.get_death_ref()
if death_ref: if death_ref:
event = self.database.get_event_from_handle(death_ref.ref) event = self.database.get_event_from_handle(death_ref.ref)
self.doc.write_text(get_date( event )) self.doc.write_text(get_date(event))
self.doc.end_paragraph() self.doc.end_paragraph()
self.doc.end_cell() self.doc.end_cell()
@@ -215,22 +218,23 @@ class TagReport(Report):
self.doc.end_table() self.doc.end_table()
def write_families(self): def write_families(self):
""" write the families associated with the tag """
flist = self.database.iter_family_handles() flist = self.database.iter_family_handles()
FilterClass = GenericFilterFactory('Family') filter_class = GenericFilterFactory('Family')
filter = FilterClass() a_filter = filter_class()
filter.add_rule(rules.family.HasTag([self.tag])) a_filter.add_rule(rules.family.HasTag([self.tag]))
fam_list = filter.apply(self.database, flist) fam_list = a_filter.apply(self.database, flist)
if not fam_list: if not fam_list:
return return
self.doc.start_paragraph("TR-Heading") self.doc.start_paragraph("TR-Heading")
header = self._("Families") header = self._("Families")
mark = IndexMark(header,INDEX_TYPE_TOC, 2) mark = IndexMark(header, INDEX_TYPE_TOC, 2)
self.doc.write_text(header, mark) self.doc.write_text(header, mark)
self.doc.end_paragraph() self.doc.end_paragraph()
self.doc.start_table('FamilyTable','TR-Table') self.doc.start_table('FamilyTable', 'TR-Table')
self.doc.start_row() self.doc.start_row()
@@ -294,7 +298,7 @@ class TagReport(Report):
self.doc.start_cell('TR-TableCell') self.doc.start_cell('TR-TableCell')
self.doc.start_paragraph('TR-Normal') self.doc.start_paragraph('TR-Normal')
relation = family.get_relationship() relation = family.get_relationship()
self.doc.write_text(str(relation) ) self.doc.write_text(str(relation))
self.doc.end_paragraph() self.doc.end_paragraph()
self.doc.end_cell() self.doc.end_cell()
@@ -303,11 +307,12 @@ class TagReport(Report):
self.doc.end_table() self.doc.end_table()
def write_events(self): def write_events(self):
""" write the events associated with the tag """
elist = self.database.get_event_handles() elist = self.database.get_event_handles()
FilterClass = GenericFilterFactory('Event') filter_class = GenericFilterFactory('Event')
filter = FilterClass() a_filter = filter_class()
filter.add_rule(rules.event.HasTag([self.tag])) a_filter.add_rule(rules.event.HasTag([self.tag]))
event_list = filter.apply(self.database, elist) event_list = a_filter.apply(self.database, elist)
if not event_list: if not event_list:
return return
@@ -318,7 +323,7 @@ class TagReport(Report):
self.doc.write_text(header, mark) self.doc.write_text(header, mark)
self.doc.end_paragraph() self.doc.end_paragraph()
self.doc.start_table('EventTable','TR-Table') self.doc.start_table('EventTable', 'TR-Table')
self.doc.start_row() self.doc.start_row()
@@ -385,11 +390,12 @@ class TagReport(Report):
self.doc.end_table() self.doc.end_table()
def write_places(self): def write_places(self):
""" write the places associated with the tag """
plist = self.database.get_place_handles() plist = self.database.get_place_handles()
FilterClass = GenericFilterFactory('Place') filter_class = GenericFilterFactory('Place')
filter = FilterClass() a_filter = filter_class()
filter.add_rule(rules.place.HasTag([self.tag])) a_filter.add_rule(rules.place.HasTag([self.tag]))
place_list = filter.apply(self.database, plist) place_list = a_filter.apply(self.database, plist)
if not place_list: if not place_list:
return return
@@ -400,7 +406,7 @@ class TagReport(Report):
self.doc.write_text(header, mark) self.doc.write_text(header, mark)
self.doc.end_paragraph() self.doc.end_paragraph()
self.doc.start_table('PlaceTable','TR-Table') self.doc.start_table('PlaceTable', 'TR-Table')
self.doc.start_row() self.doc.start_row()
@@ -465,11 +471,12 @@ class TagReport(Report):
self.doc.end_table() self.doc.end_table()
def write_notes(self): def write_notes(self):
""" write the notes associated with the tag """
nlist = self.database.get_note_handles() nlist = self.database.get_note_handles()
FilterClass = GenericFilterFactory('Note') filter_class = GenericFilterFactory('Note')
filter = FilterClass() a_filter = filter_class()
filter.add_rule(rules.note.HasTag([self.tag])) a_filter.add_rule(rules.note.HasTag([self.tag]))
note_list = filter.apply(self.database, nlist) note_list = a_filter.apply(self.database, nlist)
if not note_list: if not note_list:
return return
@@ -477,10 +484,10 @@ class TagReport(Report):
self.doc.start_paragraph("TR-Heading") self.doc.start_paragraph("TR-Heading")
header = self._("Notes") header = self._("Notes")
mark = IndexMark(header, INDEX_TYPE_TOC, 2) mark = IndexMark(header, INDEX_TYPE_TOC, 2)
self.doc.write_text(header ,mark) self.doc.write_text(header, mark)
self.doc.end_paragraph() self.doc.end_paragraph()
self.doc.start_table('NoteTable','TR-Table') self.doc.start_table('NoteTable', 'TR-Table')
self.doc.start_row() self.doc.start_row()
@@ -517,17 +524,15 @@ class TagReport(Report):
self.doc.start_cell('TR-TableCell') self.doc.start_cell('TR-TableCell')
self.doc.start_paragraph('TR-Normal') self.doc.start_paragraph('TR-Normal')
type = note.get_type() note_type = note.get_type()
self.doc.write_text(str(type)) self.doc.write_text(str(note_type))
self.doc.end_paragraph() self.doc.end_paragraph()
self.doc.end_cell() self.doc.end_cell()
self.doc.start_cell('TR-TableCell', 2) self.doc.start_cell('TR-TableCell', 2)
self.doc.write_styled_note(note.get_styledtext(), self.doc.write_styled_note(
note.get_format(), 'TR-Note', note.get_styledtext(), note.get_format(), 'TR-Note',
contains_html = (note.get_type() contains_html=((note.get_type() == NoteType.HTML_CODE)))
== NoteType.HTML_CODE)
)
self.doc.end_cell() self.doc.end_cell()
self.doc.end_row() self.doc.end_row()
@@ -535,11 +540,12 @@ class TagReport(Report):
self.doc.end_table() self.doc.end_table()
def write_media(self): def write_media(self):
""" write the media associated with the tag """
mlist = self.database.get_media_handles(sort_handles=True) mlist = self.database.get_media_handles(sort_handles=True)
FilterClass = GenericFilterFactory('Media') filter_class = GenericFilterFactory('Media')
filter = FilterClass() a_filter = filter_class()
filter.add_rule(rules.media.HasTag([self.tag])) a_filter.add_rule(rules.media.HasTag([self.tag]))
media_list = filter.apply(self.database, mlist) media_list = a_filter.apply(self.database, mlist)
if not media_list: if not media_list:
return return
@@ -547,10 +553,10 @@ class TagReport(Report):
self.doc.start_paragraph("TR-Heading") self.doc.start_paragraph("TR-Heading")
header = self._("Media") header = self._("Media")
mark = IndexMark(header, INDEX_TYPE_TOC, 2) mark = IndexMark(header, INDEX_TYPE_TOC, 2)
self.doc.write_text(header ,mark) self.doc.write_text(header, mark)
self.doc.end_paragraph() self.doc.end_paragraph()
self.doc.start_table('MediaTable','TR-Table') self.doc.start_table('MediaTable', 'TR-Table')
self.doc.start_row() self.doc.start_row()
@@ -618,11 +624,12 @@ class TagReport(Report):
self.doc.end_table() self.doc.end_table()
def write_repositories(self): def write_repositories(self):
""" write the repositories associated with the tag """
rlist = self.database.get_repository_handles() rlist = self.database.get_repository_handles()
FilterClass = GenericFilterFactory('Repository') filter_class = GenericFilterFactory('Repository')
filter = FilterClass() a_filter = filter_class()
filter.add_rule(rules.repository.HasTag([self.tag])) a_filter.add_rule(rules.repository.HasTag([self.tag]))
repo_list = filter.apply(self.database, rlist) repo_list = a_filter.apply(self.database, rlist)
if not repo_list: if not repo_list:
return return
@@ -630,10 +637,10 @@ class TagReport(Report):
self.doc.start_paragraph("TR-Heading") self.doc.start_paragraph("TR-Heading")
header = self._("Repositories") header = self._("Repositories")
mark = IndexMark(header, INDEX_TYPE_TOC, 2) mark = IndexMark(header, INDEX_TYPE_TOC, 2)
self.doc.write_text(header ,mark) self.doc.write_text(header, mark)
self.doc.end_paragraph() self.doc.end_paragraph()
self.doc.start_table('ReopTable','TR-Table') self.doc.start_table('ReopTable', 'TR-Table')
self.doc.start_row() self.doc.start_row()
@@ -702,11 +709,12 @@ class TagReport(Report):
self.doc.end_table() self.doc.end_table()
def write_sources(self): def write_sources(self):
""" write the sources associated with the tag """
slist = self.database.get_source_handles(sort_handles=True) slist = self.database.get_source_handles(sort_handles=True)
FilterClass = GenericFilterFactory('Source') filter_class = GenericFilterFactory('Source')
filter = FilterClass() a_filter = filter_class()
filter.add_rule(rules.source.HasTag([self.tag])) a_filter.add_rule(rules.source.HasTag([self.tag]))
source_list = filter.apply(self.database, slist) source_list = a_filter.apply(self.database, slist)
if not source_list: if not source_list:
return return
@@ -714,10 +722,10 @@ class TagReport(Report):
self.doc.start_paragraph("TR-Heading") self.doc.start_paragraph("TR-Heading")
header = self._("Source") header = self._("Source")
mark = IndexMark(header, INDEX_TYPE_TOC, 2) mark = IndexMark(header, INDEX_TYPE_TOC, 2)
self.doc.write_text(header ,mark) self.doc.write_text(header, mark)
self.doc.end_paragraph() self.doc.end_paragraph()
self.doc.start_table('SourceTable','TR-Table') self.doc.start_table('SourceTable', 'TR-Table')
self.doc.start_row() self.doc.start_row()
@@ -781,11 +789,12 @@ class TagReport(Report):
self.doc.end_table() self.doc.end_table()
def write_citations(self): def write_citations(self):
""" write the citations associated with the tag """
clist = self.database.get_citation_handles(sort_handles=True) clist = self.database.get_citation_handles(sort_handles=True)
FilterClass = GenericFilterFactory('Citation') filter_class = GenericFilterFactory('Citation')
filter = FilterClass() a_filter = filter_class()
filter.add_rule(rules.citation.HasTag([self.tag])) a_filter.add_rule(rules.citation.HasTag([self.tag]))
citation_list = filter.apply(self.database, clist) citation_list = a_filter.apply(self.database, clist)
if not citation_list: if not citation_list:
return return
@@ -793,10 +802,10 @@ class TagReport(Report):
self.doc.start_paragraph("TR-Heading") self.doc.start_paragraph("TR-Heading")
header = self._("Citations") header = self._("Citations")
mark = IndexMark(header, INDEX_TYPE_TOC, 2) mark = IndexMark(header, INDEX_TYPE_TOC, 2)
self.doc.write_text(header ,mark) self.doc.write_text(header, mark)
self.doc.end_paragraph() self.doc.end_paragraph()
self.doc.start_table('CitationTable','TR-Table') self.doc.start_table('CitationTable', 'TR-Table')
self.doc.start_row() self.doc.start_row()
@@ -869,6 +878,7 @@ class TagReport(Report):
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class TagOptions(MenuReportOptions): class TagOptions(MenuReportOptions):
""" Options for the Tag Report """
def __init__(self, name, dbase): def __init__(self, name, dbase):
self.__db = dbase self.__db = dbase
@@ -893,7 +903,7 @@ class TagOptions(MenuReportOptions):
tag_option = EnumeratedListOption(_('Tag'), '') tag_option = EnumeratedListOption(_('Tag'), '')
tag_option.add_item('', '') tag_option.add_item('', '')
tag_option.set_help( _("The tag to use for the report")) tag_option.set_help(_("The tag to use for the report"))
menu.add_option(category_name, "tag", tag_option) menu.add_option(category_name, "tag", tag_option)
stdoptions.add_name_format_option(menu, category_name) stdoptions.add_name_format_option(menu, category_name)
@@ -904,21 +914,21 @@ class TagOptions(MenuReportOptions):
stdoptions.add_localization_option(menu, category_name) stdoptions.add_localization_option(menu, category_name)
def make_default_style(self,default_style): def make_default_style(self, default_style):
"""Make the default output style for the Tag Report.""" """Make the default output style for the Tag Report."""
# Paragraph Styles # Paragraph Styles
f = FontStyle() font = FontStyle()
f.set_size(16) font.set_size(16)
f.set_type_face(FONT_SANS_SERIF) font.set_type_face(FONT_SANS_SERIF)
f.set_bold(1) font.set_bold(1)
p = ParagraphStyle() para = ParagraphStyle()
p.set_header_level(1) para.set_header_level(1)
p.set_top_margin(ReportUtils.pt2cm(3)) para.set_top_margin(ReportUtils.pt2cm(3))
p.set_bottom_margin(ReportUtils.pt2cm(3)) para.set_bottom_margin(ReportUtils.pt2cm(3))
p.set_font(f) para.set_font(font)
p.set_alignment(PARA_ALIGN_CENTER) para.set_alignment(PARA_ALIGN_CENTER)
p.set_description(_("The style used for the title of the page.")) para.set_description(_("The style used for the title of the page."))
default_style.add_paragraph_style("TR-Title", p) default_style.add_paragraph_style("TR-Title", para)
font = FontStyle() font = FontStyle()
font.set(face=FONT_SANS_SERIF, size=12, bold=1) font.set(face=FONT_SANS_SERIF, size=12, bold=1)
@@ -943,31 +953,31 @@ class TagOptions(MenuReportOptions):
font = FontStyle() font = FontStyle()
font.set_size(12) font.set_size(12)
p = ParagraphStyle() para = ParagraphStyle()
p.set(first_indent=-0.75, lmargin=.75) para.set(first_indent=-0.75, lmargin=.75)
p.set_font(font) para.set_font(font)
p.set_top_margin(ReportUtils.pt2cm(3)) para.set_top_margin(ReportUtils.pt2cm(3))
p.set_bottom_margin(ReportUtils.pt2cm(3)) para.set_bottom_margin(ReportUtils.pt2cm(3))
p.set_description(_('The basic style used for the text display.')) para.set_description(_('The basic style used for the text display.'))
default_style.add_paragraph_style("TR-Normal", p) default_style.add_paragraph_style("TR-Normal", para)
font = FontStyle() font = FontStyle()
font.set_size(12) font.set_size(12)
font.set_bold(True) font.set_bold(True)
p = ParagraphStyle() para = ParagraphStyle()
p.set(first_indent=-0.75, lmargin=.75) para.set(first_indent=-0.75, lmargin=.75)
p.set_font(font) para.set_font(font)
p.set_top_margin(ReportUtils.pt2cm(3)) para.set_top_margin(ReportUtils.pt2cm(3))
p.set_bottom_margin(ReportUtils.pt2cm(3)) para.set_bottom_margin(ReportUtils.pt2cm(3))
p.set_description(_('The basic style used for table headings.')) para.set_description(_('The basic style used for table headings.'))
default_style.add_paragraph_style("TR-Normal-Bold", p) default_style.add_paragraph_style("TR-Normal-Bold", para)
para = ParagraphStyle() para = ParagraphStyle()
p.set(first_indent=-0.75, lmargin=.75) para.set(first_indent=-0.75, lmargin=.75)
para.set_top_margin(ReportUtils.pt2cm(3)) para.set_top_margin(ReportUtils.pt2cm(3))
para.set_bottom_margin(ReportUtils.pt2cm(3)) para.set_bottom_margin(ReportUtils.pt2cm(3))
para.set_description(_('The basic style used for the note display.')) para.set_description(_('The basic style used for the note display.'))
default_style.add_paragraph_style("TR-Note",para) default_style.add_paragraph_style("TR-Note", para)
#Table Styles #Table Styles
cell = TableCellStyle() cell = TableCellStyle()
@@ -980,4 +990,4 @@ class TagOptions(MenuReportOptions):
table.set_column_width(1, 30) table.set_column_width(1, 30)
table.set_column_width(2, 30) table.set_column_width(2, 30)
table.set_column_width(3, 30) table.set_column_width(3, 30)
default_style.add_table_style('TR-Table',table) default_style.add_table_style('TR-Table', table)