~menesis/ubuntu/raring/python-xlrd/raring

« back to all changes in this revision

Viewing changes to xlrd/formatting.py

  • Committer: Gediminas Paulauskas
  • Date: 2013-05-06 17:29:45 UTC
  • mfrom: (1.1.2)
  • Revision ID: menesis@pov.lt-20130506172945-kr4to77vsxbw4yj5
Tags: 0.9.2-0ubuntu1
* New upstream release.
* debian/rules: do not install examples or docs into /usr/lib/python*.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
    XL_FORMAT, XL_FORMAT2, \
35
35
    XLRDError
36
36
 
 
37
_cellty_from_fmtty = {
 
38
    FNU: XL_CELL_NUMBER,
 
39
    FUN: XL_CELL_NUMBER,
 
40
    FGE: XL_CELL_NUMBER,
 
41
    FDT: XL_CELL_DATE,
 
42
    FTX: XL_CELL_NUMBER, # Yes, a number can be formatted as text.
 
43
    }    
 
44
    
37
45
excel_default_palette_b5 = (
38
46
    (  0,   0,   0), (255, 255, 255), (255,   0,   0), (  0, 255,   0),
39
47
    (  0,   0, 255), (255, 255,   0), (255,   0, 255), (  0, 255, 255),
479
487
            state = 0
480
488
        assert 0 <= state <= 2
481
489
    if book.verbosity >= 4:
482
 
        print("is_date_format_string: reduced format is %r" % s, file=book.logfile)
 
490
        print("is_date_format_string: reduced format is %s" % REPR(s), file=book.logfile)
483
491
    s = fmt_bracketed_sub('', s)
484
492
    if s in non_date_formats:
485
493
        return False
614
622
            book.colour_indexes_used[cx] = 1
615
623
        elif book.verbosity:
616
624
            print("Size of colour table:", len(book.colour_map), file=book.logfile)
617
 
            print("*** Font #%d (%r): colour index 0x%04x is unknown" \
618
 
                % (font.font_index, font.name, cx), file=book.logfile)
 
625
            fprintf(self.logfile, "*** Font #%d (%r): colour index 0x%04x is unknown\n",
 
626
                font.font_index, font.name, cx)
619
627
    if book.verbosity >= 1:
620
628
        used = sorted(book.colour_indexes_used.keys())
621
629
        print("\nColour indexes used:\n%r\n" % used, file=book.logfile)
661
669
            print("WARNING *** A user-defined style has a zero-length name", file=book.logfile)
662
670
    book.style_name_map[name] = (built_in, xf_index)
663
671
    if blah:
664
 
        print("STYLE: built_in=%d xf_index=%d built_in_id=%d level=%d name=%r" \
665
 
            % (built_in, xf_index, built_in_id, level, name), file=book.logfile)
 
672
        fprintf(book.logfile, "STYLE: built_in=%d xf_index=%d built_in_id=%d level=%d name=%r\n",
 
673
            built_in, xf_index, built_in_id, level, name)
666
674
 
667
675
def check_colour_indexes_in_obj(book, obj, orig_index):
668
676
    alist = sorted(obj.__dict__.items())
945
953
            header="--- handle_xf: xf[%d] ---" % xf.xf_index,
946
954
            footer=" ",
947
955
        )
 
956
    try:
 
957
        fmt = self.format_map[xf.format_key]
 
958
        cellty = _cellty_from_fmtty[fmt.type]
 
959
    except KeyError:
 
960
        cellty = XL_CELL_NUMBER
 
961
    self._xf_index_to_xl_type_map[xf.xf_index] = cellty
 
962
 
948
963
    # Now for some assertions ...
949
964
    if self.formatting_info:
950
965
        if self.verbosity and xf.is_style and xf.parent_style_index != 0x0FFF:
981
996
            fprintf(self.logfile, msg,
982
997
                    xf.xf_index, xf.format_key, xf.format_key)
983
998
            xf.format_key = 0
984
 
        cellty_from_fmtty = {
985
 
            FNU: XL_CELL_NUMBER,
986
 
            FUN: XL_CELL_NUMBER,
987
 
            FGE: XL_CELL_NUMBER,
988
 
            FDT: XL_CELL_DATE,
989
 
            FTX: XL_CELL_NUMBER, # Yes, a number can be formatted as text.
990
 
            }
 
999
 
991
1000
        fmt = self.format_map[xf.format_key]
992
 
        cellty = cellty_from_fmtty[fmt.type]
 
1001
        cellty = _cellty_from_fmtty[fmt.type]
993
1002
        self._xf_index_to_xl_type_map[xf.xf_index] = cellty
994
1003
        # Now for some assertions etc
995
1004
        if not self.formatting_info: