diff --git a/gramps/gen/plug/report/_book.py b/gramps/gen/plug/report/_book.py index 38342751d..36b6d457a 100644 --- a/gramps/gen/plug/report/_book.py +++ b/gramps/gen/plug/report/_book.py @@ -52,7 +52,7 @@ from xml.sax.saxutils import escape #------------------------------------------------------------------------- # -# gramps modules +# Gramps modules # #------------------------------------------------------------------------- from ...const import GRAMPS_LOCALE as glocale @@ -83,6 +83,7 @@ class BookItem: def __init__(self, dbase, name): """ Create a new empty BookItem. + TODO: it should be possible to make a non-empty BookItem, a copy name: the book item is retrieved from the book item registry using name for lookup @@ -153,15 +154,21 @@ class Book: Interface into the user-defined Book -- a collection of book items. """ - def __init__(self, obj=None): + def __init__(self, obj=None, exact_copy=True): """ Create a new empty Book. - obj: if not None, creates the Book from the values in - obj, instead of creating an empty Book. + @param obj: if not None, creates the Book from obj, from the + items in obj, instead of creating an empty Book. + @type obj: a :class:`.Book` instance + @param exact_copy: if True (and obj is not None) the exact same + BookItem objects will be in the new Book; + if False (and obj is not None) the same number + and same type of BookItem objects will be created + @type exact_copy: boolean """ - self.name = "" + self.name = "" # this is tested for, in several places self.dbname = "" self.paper_name = None self.paper_orientation = None @@ -170,10 +177,14 @@ class Book: self.paper_margins = None self.paper_format = None self.paper_output = None + self.item_list = [] if obj: - self.item_list = obj.item_list - else: - self.item_list = [] + if exact_copy: + self.item_list = obj.item_list + else: + for item in obj.get_item_list(): + self.item_list.append(BookItem(item.dbase, + item.get_name())) def set_name(self, name): """ @@ -481,8 +492,8 @@ class BookList: for name in sorted(self.bookmap): # enable a diff of archived copies book = self.get_book(name) dbname = book.get_dbname() - b_f.write(' \n' % (name, dbname)) + b_f.write(' ' + '\n' % (name, dbname)) for item in book.get_item_list(): b_f.write(' \n' % ( @@ -517,33 +528,36 @@ class BookList: option_type, value)) - b_f.write('