home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_1085 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  5.3 KB  |  155 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import sys
  5.  
  6. class BorderParse:
  7.     
  8.     def __init__(self):
  9.         self._BorderParse__border_dict = {
  10.             'bor-t-r-hi': 'border-table-row-horizontal-inside',
  11.             'bor-t-r-vi': 'border-table-row-vertical-inside',
  12.             'bor-t-r-to': 'border-table-row-top',
  13.             'bor-t-r-le': 'border-table-row-left',
  14.             'bor-t-r-bo': 'border-table-row-bottom',
  15.             'bor-t-r-ri': 'border-table-row-right',
  16.             'bor-cel-bo': 'border-cell-bottom',
  17.             'bor-cel-to': 'border-cell-top',
  18.             'bor-cel-le': 'border-cell-left',
  19.             'bor-cel-ri': 'border-cell-right',
  20.             'bor-par-bo': 'border-paragraph-bottom',
  21.             'bor-par-to': 'border-paragraph-top',
  22.             'bor-par-le': 'border-paragraph-left',
  23.             'bor-par-ri': 'border-paragraph-right',
  24.             'bor-par-bx': 'border-paragraph-box',
  25.             'bor-for-ev': 'border-for-every-paragraph',
  26.             'bor-outsid': 'border-outside',
  27.             'bor-none__': 'border',
  28.             'bdr-li-wid': 'line-width',
  29.             'bdr-sp-wid': 'padding',
  30.             'bdr-color_': 'color' }
  31.         self._BorderParse__border_style_dict = {
  32.             'bdr-single': 'single',
  33.             'bdr-doubtb': 'double-thickness-border',
  34.             'bdr-shadow': 'shadowed-border',
  35.             'bdr-double': 'double-border',
  36.             'bdr-dotted': 'dotted-border',
  37.             'bdr-dashed': 'dashed',
  38.             'bdr-hair__': 'hairline',
  39.             'bdr-inset_': 'inset',
  40.             'bdr-das-sm': 'dash-small',
  41.             'bdr-dot-sm': 'dot-dash',
  42.             'bdr-dot-do': 'dot-dot-dash',
  43.             'bdr-outset': 'outset',
  44.             'bdr-trippl': 'tripple',
  45.             'bdr-thsm__': 'thick-thin-small',
  46.             'bdr-htsm__': 'thin-thick-small',
  47.             'bdr-hthsm_': 'thin-thick-thin-small',
  48.             'bdr-thm___': 'thick-thin-medium',
  49.             'bdr-htm___': 'thin-thick-medium',
  50.             'bdr-hthm__': 'thin-thick-thin-medium',
  51.             'bdr-thl___': 'thick-thin-large',
  52.             'bdr-hthl__': 'thin-thick-thin-large',
  53.             'bdr-wavy__': 'wavy',
  54.             'bdr-d-wav_': 'double-wavy',
  55.             'bdr-strip_': 'striped',
  56.             'bdr-embos_': 'emboss',
  57.             'bdr-engra_': 'engrave',
  58.             'bdr-frame_': 'frame' }
  59.  
  60.     
  61.     def parse_border(self, line):
  62.         border_dict = { }
  63.         border_style_dict = { }
  64.         border_style_list = []
  65.         border_type = self._BorderParse__border_dict.get(line[6:16])
  66.         if not border_type:
  67.             sys.stderr.write('module is border_parse.py\nfunction is parse_border\ntoken does not have a dictionary value\ntoken is "%s"' % line)
  68.             return border_dict
  69.         att_line = line[20:-1]
  70.         atts = att_line.split('|')
  71.         if len(atts) == 1 and atts[0] == '':
  72.             border_dict[border_type] = 'none'
  73.             return border_dict
  74.         for att in atts:
  75.             values = att.split(':')
  76.             style_att = self._BorderParse__border_style_dict.get(att)
  77.             if style_att:
  78.                 att = '%s-%s' % (border_type, att)
  79.                 border_style_dict[att] = value
  80.                 border_style_list.append(style_att)
  81.                 continue
  82.             None if len(values) == 2 else border_type
  83.             att = self._BorderParse__border_dict.get(att)
  84.             if not att:
  85.                 sys.stderr.write('module is border_parse_def.py\nfunction is parse_border\ntoken does not have an att value\nline is "%s"' % line)
  86.             
  87.             att = '%s-%s' % (border_type, att)
  88.             border_dict[att] = value
  89.         
  90.         new_border_dict = self._BorderParse__determine_styles(border_type, border_style_list)
  91.         border_dict.update(new_border_dict)
  92.         return border_dict
  93.  
  94.     
  95.     def __determine_styles(self, border_type, border_style_list):
  96.         new_border_dict = { }
  97.         att = '%s-style' % border_type
  98.         if 'shadowed-border' in border_style_list:
  99.             new_border_dict[att] = 'shadowed'
  100.         elif 'engraved' in border_style_list:
  101.             new_border_dict[att] = 'engraved'
  102.         elif 'emboss' in border_style_list:
  103.             new_border_dict[att] = 'emboss'
  104.         elif 'striped' in border_style_list:
  105.             new_border_dict[att] = 'striped'
  106.         elif 'thin-thick-thin-small' in border_style_list:
  107.             new_border_dict[att] = 'thin-thick-thin-small'
  108.         elif 'thick-thin-large' in border_style_list:
  109.             new_border_dict[att] = 'thick-thin-large'
  110.         elif 'thin-thick-thin-medium' in border_style_list:
  111.             new_border_dict[att] = 'thin-thick-thin-medium'
  112.         elif 'thin-thick-medium' in border_style_list:
  113.             new_border_dict[att] = 'thin-thick-medium'
  114.         elif 'thick-thin-medium' in border_style_list:
  115.             new_border_dict[att] = 'thick-thin-medium'
  116.         elif 'thick-thin-small' in border_style_list:
  117.             new_border_dict[att] = 'thick-thin-small'
  118.         elif 'thick-thin-small' in border_style_list:
  119.             new_border_dict[att] = 'thick-thin-small'
  120.         elif 'double-wavy' in border_style_list:
  121.             new_border_dict[att] = 'double-wavy'
  122.         elif 'dot-dot-dash' in border_style_list:
  123.             new_border_dict[att] = 'dot-dot-dash'
  124.         elif 'dot-dash' in border_style_list:
  125.             new_border_dict[att] = 'dot-dash'
  126.         elif 'dotted-border' in border_style_list:
  127.             new_border_dict[att] = 'dotted'
  128.         elif 'wavy' in border_style_list:
  129.             new_border_dict[att] = 'wavy'
  130.         elif 'dash-small' in border_style_list:
  131.             new_border_dict[att] = 'dash-small'
  132.         elif 'dashed' in border_style_list:
  133.             new_border_dict[att] = 'dashed'
  134.         elif 'frame' in border_style_list:
  135.             new_border_dict[att] = 'frame'
  136.         elif 'inset' in border_style_list:
  137.             new_border_dict[att] = 'inset'
  138.         elif 'outset' in border_style_list:
  139.             new_border_dict[att] = 'outset'
  140.         elif 'tripple-border' in border_style_list:
  141.             new_border_dict[att] = 'tripple'
  142.         elif 'double-border' in border_style_list:
  143.             new_border_dict[att] = 'double'
  144.         elif 'double-thickness-border' in border_style_list:
  145.             new_border_dict[att] = 'double-thickness'
  146.         elif 'hairline' in border_style_list:
  147.             new_border_dict[att] = 'hairline'
  148.         elif 'single' in border_style_list:
  149.             new_border_dict[att] = 'single'
  150.         else:
  151.             new_border_dict[att] = border_style_list[0]
  152.         return new_border_dict
  153.  
  154.  
  155.