0004705: Book Report does not work from CLI (Patch from Paul Franklin).
svn: r17870
This commit is contained in:
parent
ab8c2d8693
commit
d25248ccb8
@ -146,7 +146,6 @@ def _validate_options(options, dbase):
|
|||||||
dbase: the database the options will be applied to
|
dbase: the database the options will be applied to
|
||||||
"""
|
"""
|
||||||
if not hasattr(options, "menu"):
|
if not hasattr(options, "menu"):
|
||||||
print 'no menu'
|
|
||||||
return
|
return
|
||||||
menu = options.menu
|
menu = options.menu
|
||||||
|
|
||||||
@ -322,6 +321,15 @@ class CommandLineReport(object):
|
|||||||
"""
|
"""
|
||||||
Initialize the options that are defined by each report.
|
Initialize the options that are defined by each report.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if self.category == CATEGORY_BOOK: # a Book Report has no "menu"
|
||||||
|
for key in self.option_class.options_dict:
|
||||||
|
self.options_dict[key] = self.option_class.options_dict[key]
|
||||||
|
self.options_help[key] = \
|
||||||
|
self.option_class.options_help[key][:3]
|
||||||
|
# a Book Report can't have HTML output so "css" is meaningless
|
||||||
|
self.options_dict.pop('css')
|
||||||
|
|
||||||
if not hasattr(self.option_class, "menu"):
|
if not hasattr(self.option_class, "menu"):
|
||||||
return
|
return
|
||||||
menu = self.option_class.menu
|
menu = self.option_class.menu
|
||||||
@ -400,9 +408,10 @@ class CommandLineReport(object):
|
|||||||
Load the options that the user has entered.
|
Load the options that the user has entered.
|
||||||
"""
|
"""
|
||||||
if not hasattr(self.option_class, "menu"):
|
if not hasattr(self.option_class, "menu"):
|
||||||
return
|
menu = None
|
||||||
menu = self.option_class.menu
|
else:
|
||||||
menu_opt_names = menu.get_all_option_names()
|
menu = self.option_class.menu
|
||||||
|
menu_opt_names = menu.get_all_option_names()
|
||||||
for opt in self.options_str_dict:
|
for opt in self.options_str_dict:
|
||||||
if opt in self.options_dict:
|
if opt in self.options_dict:
|
||||||
self.options_dict[opt] = \
|
self.options_dict[opt] = \
|
||||||
@ -412,7 +421,7 @@ class CommandLineReport(object):
|
|||||||
self.option_class.handler.options_dict[opt] = \
|
self.option_class.handler.options_dict[opt] = \
|
||||||
self.options_dict[opt]
|
self.options_dict[opt]
|
||||||
|
|
||||||
if opt in menu_opt_names:
|
if menu and opt in menu_opt_names:
|
||||||
option = menu.get_option_by_name(opt)
|
option = menu.get_option_by_name(opt)
|
||||||
option.set_value(self.options_dict[opt])
|
option.set_value(self.options_dict[opt])
|
||||||
|
|
||||||
@ -503,12 +512,12 @@ class CommandLineReport(object):
|
|||||||
elif self.show in self.options_help:
|
elif self.show in self.options_help:
|
||||||
opt = self.options_help[self.show]
|
opt = self.options_help[self.show]
|
||||||
tabs = '\t\t' if len(self.show) < 10 else '\t'
|
tabs = '\t\t' if len(self.show) < 10 else '\t'
|
||||||
print ' %s%s%s%s' % (self.show, tabs, opt[0], opt[1])
|
print ' %s%s%s (%s)' % (self.show, tabs, opt[1], opt[0])
|
||||||
print " Available values are:"
|
print " Available values are:"
|
||||||
vals = opt[2]
|
vals = opt[2]
|
||||||
if isinstance(vals, (list, tuple)):
|
if isinstance(vals, (list, tuple)):
|
||||||
for val in vals:
|
for val in vals:
|
||||||
optmsg = " %s" % val
|
optmsg = " %s" % val
|
||||||
print optmsg.encode(sys.getfilesystemencoding())
|
print optmsg.encode(sys.getfilesystemencoding())
|
||||||
else:
|
else:
|
||||||
optmsg = " %s" % opt[2]
|
optmsg = " %s" % opt[2]
|
||||||
|
@ -72,7 +72,7 @@ import Utils
|
|||||||
import ListModel
|
import ListModel
|
||||||
import Errors
|
import Errors
|
||||||
from gui.pluginmanager import GuiPluginManager
|
from gui.pluginmanager import GuiPluginManager
|
||||||
from gen.plug.docgen import StyleSheet, StyleSheetList
|
from gen.plug.docgen import StyleSheet, StyleSheetList, PaperStyle
|
||||||
from QuestionDialog import WarningDialog, ErrorDialog
|
from QuestionDialog import WarningDialog, ErrorDialog
|
||||||
from gen.plug.menu import PersonOption, FilterOption, FamilyOption
|
from gen.plug.menu import PersonOption, FilterOption, FamilyOption
|
||||||
import ManagedWindow
|
import ManagedWindow
|
||||||
@ -700,7 +700,7 @@ class BookOptions(ReportOptions):
|
|||||||
'bookname' : '',
|
'bookname' : '',
|
||||||
}
|
}
|
||||||
self.options_help = {
|
self.options_help = {
|
||||||
'bookname' : ("=name","Name of the book. MANDATORY",
|
'bookname' : ("=name",_("Name of the book. MANDATORY"),
|
||||||
BookList('books.xml',dbase).get_book_names(),
|
BookList('books.xml',dbase).get_book_names(),
|
||||||
False),
|
False),
|
||||||
}
|
}
|
||||||
@ -1301,6 +1301,9 @@ def cl_report(database, name, category, options_str_dict):
|
|||||||
book_list = BookList('books.xml', database)
|
book_list = BookList('books.xml', database)
|
||||||
book_name = clr.options_dict['bookname']
|
book_name = clr.options_dict['bookname']
|
||||||
if book_name:
|
if book_name:
|
||||||
|
if book_name not in book_list.get_book_names():
|
||||||
|
print _("No such book '%s'") % book_name
|
||||||
|
return
|
||||||
book = book_list.get_book(book_name)
|
book = book_list.get_book(book_name)
|
||||||
else:
|
else:
|
||||||
print _("Please specify a book name")
|
print _("Please specify a book name")
|
||||||
@ -1326,8 +1329,34 @@ def cl_report(database, name, category, options_str_dict):
|
|||||||
this_style_name,
|
this_style_name,
|
||||||
style_sheet.get_paragraph_style(this_style_name))
|
style_sheet.get_paragraph_style(this_style_name))
|
||||||
|
|
||||||
|
for this_style_name in style_sheet.get_draw_style_names():
|
||||||
|
selected_style.add_draw_style(
|
||||||
|
this_style_name,
|
||||||
|
style_sheet.get_draw_style(this_style_name))
|
||||||
|
|
||||||
|
for this_style_name in style_sheet.get_table_style_names():
|
||||||
|
selected_style.add_table_style(
|
||||||
|
this_style_name,
|
||||||
|
style_sheet.get_table_style(this_style_name))
|
||||||
|
|
||||||
|
for this_style_name in style_sheet.get_cell_style_names():
|
||||||
|
selected_style.add_cell_style(
|
||||||
|
this_style_name,
|
||||||
|
style_sheet.get_cell_style(this_style_name))
|
||||||
|
|
||||||
|
# The option values were loaded magically by the book parser.
|
||||||
|
# But they still need to be applied to the menu options.
|
||||||
|
opt_dict = item.option_class.options_dict
|
||||||
|
menu = item.option_class.menu
|
||||||
|
for optname in opt_dict:
|
||||||
|
menu_option = menu.get_option_by_name(optname)
|
||||||
|
if menu_option:
|
||||||
|
menu_option.set_value(opt_dict[optname])
|
||||||
|
|
||||||
# write report
|
# write report
|
||||||
doc = clr.format(selected_style, clr.paper, clr.template_name, clr.orien)
|
doc = clr.format(selected_style,
|
||||||
|
PaperStyle(clr.paper, clr.orien, clr.marginl,
|
||||||
|
clr.marginr, clr.margint, clr.marginb))
|
||||||
rptlist = []
|
rptlist = []
|
||||||
for item in book.get_item_list():
|
for item in book.get_item_list():
|
||||||
item.option_class.set_document(doc)
|
item.option_class.set_document(doc)
|
||||||
|
Loading…
Reference in New Issue
Block a user