'Transform book metadata from plugboard templates'

def _xform_metadata_via_plugboard(self, book, format):

    if self.verbose:
        logger().info(('    %s._xform_metadata_via_plugboard()' % self.__class__.__name__))
    if self.plugboard_func:
        pb = self.plugboard_func(self.DEVICE_PLUGBOARD_NAME, format, self.plugboards)
        newmi = book.deepcopy_metadata()
        newmi.template_to_attribute(book, pb)
        if ((pb is not None) and self.verbose):
            logger().info(("                            title:    '%s'    %s" % (book.title, ((">>>    '%s'" % newmi.title) if (book.title != newmi.title) else ''))))
            logger().info(('        title_sort:    %s    %s' % (book.title_sort, (('>>>    %s' % newmi.title_sort) if (book.title_sort != newmi.title_sort) else ''))))
            logger().info(('                    authors:    %s    %s' % (book.authors, (('>>>    %s' % newmi.authors) if (book.authors != newmi.authors) else ''))))
            logger().info(('    author_sort:    %s    %s' % (book.author_sort, (('>>>    %s' % newmi.author_sort) if (book.author_sort != newmi.author_sort) else ''))))
            logger().info(('                language:    %s    %s' % (book.language, (('>>>    %s' % newmi.language) if (book.language != newmi.language) else ''))))
            logger().info(('            publisher:    %s    %s' % (book.publisher, (('>>>    %s' % newmi.publisher) if (book.publisher != newmi.publisher) else ''))))
            logger().info(('                                tags:    %s    %s' % (book.tags, (('>>>    %s' % newmi.tags) if (book.tags != newmi.tags) else ''))))
        elif self.verbose:
            logger()('        matching    plugboard    not    found')
    else:
        newmi = book
    return newmi
