Show
Ignore:
Timestamp:
01/22/09 05:11:25 (19 months ago)
Author:
Ga?tan de Menten <ged@…>
Branch:
default
Message:

- prefix make_href and guess_type methods by "relatorio" so that we don't

risk a collision with user-provided methods

- removed the second parameter to make_href which wasn't used
- added some more comments/docstrings

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • relatorio/templates/opendocument.py

    r97 r98  
    8686        self.context = context.copy() 
    8787 
    88     def __call__(self, expr, name): 
    89         #FIXME: name argument is unused 
     88    def __call__(self, expr): 
    9089        bitstream, mimetype = expr 
    9190        if isinstance(bitstream, Report): 
     
    103102 
    104103class ColumnCounter: 
    105     """A class used to add the correct number of column definitions to a 
    106     table containing an horizontal repetition" 
     104    """A class used to count the actual maximum number of cells (and thus 
     105    columns) a table contains accross its rows. 
    107106    """ 
    108107    def __init__(self): 
     
    122121 
    123122def wrap_nodes_between(first, last, new_parent): 
     123    """An helper function to move all nodes between two nodes to a new node 
     124    and add that new node to their former parent. The boundary nodes are 
     125    removed in the process. 
     126    """ 
    124127    old_parent = first.getparent() 
    125128    for node in first.itersiblings(): 
     
    449452                # The grand-parent tag is a table cell we should set the 
    450453                # correct value and type for this cell. 
    451                 dico = "{'%s': %s, '%s': guess_type(%s)}" 
     454                dico = "{'%s': %s, '%s': __relatorio_guess_type(%s)}" 
    452455                parent.attrib[py_attrs_attr] = dico % (office_name, expr, 
    453                                                      office_valuetype, expr) 
     456                                                       office_valuetype, expr) 
    454457                parent.attrib.pop(office_valuetype, None) 
    455458                parent.attrib.pop(office_name, None) 
     
    457460    def _handle_row_spanned_column_loops(self, parsed, outer_o_node, 
    458461                                         opening_pos, closing_pos): 
     462        """handles column repetitions which span several rows, by duplicating 
     463        the py:for node for each row, and make the loops work on a copy of the 
     464        original iterable as to not exhaust generators.""" 
    459465        _, directive, attr, a_val = parsed 
    460466        table_rowspan_attr = '{%s}number-rows-spanned' \ 
     
    516522 
    517523    def _handle_images(self, tree): 
    518         "replaces all draw:frame named 'image: ...' by a draw:image node" 
     524        "replaces all draw:frame named 'image: ...' by draw:image nodes" 
    519525        draw_name = '{%s}name' % self.namespaces['draw'] 
    520526        draw_image = '{%s}image' % self.namespaces['draw'] 
     
    523529        for draw in tree.xpath(xpath_expr, namespaces=self.namespaces): 
    524530            d_name = draw.attrib[draw_name] 
    525             attr_expr = "make_href(%s, %r)" % (d_name[7:], d_name[7:]) 
     531            attr_expr = "__relatorio_make_href(%s)" % d_name[7:] 
    526532            image_node = EtreeElement(draw_image, 
    527533                                      attrib={py_attrs: attr_expr}, 
     
    540546        "creates the RelatorioStream." 
    541547        serializer = OOSerializer(self.filepath) 
    542         kwargs['make_href'] = ImageHref(serializer.outzip, kwargs) 
    543         kwargs['guess_type'] = guess_type 
     548        kwargs['__relatorio_make_href'] = ImageHref(serializer.outzip, kwargs) 
     549        kwargs['__relatorio_guess_type'] = guess_type 
    544550 
    545551        counter = ColumnCounter()