home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 January / maximum-cd-2011-01.iso / DiscContents / calibre-0.7.26.msi / file_2343 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-10-31  |  1.9 KB  |  79 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. esc = '\x1b['
  5. codes = { }
  6. codes[''] = ''
  7. codes['reset'] = esc + '39;49;00m'
  8. codes['bold'] = esc + '01m'
  9. codes['faint'] = esc + '02m'
  10. codes['standout'] = esc + '03m'
  11. codes['underline'] = esc + '04m'
  12. codes['blink'] = esc + '05m'
  13. codes['overline'] = esc + '06m'
  14. dark_colors = [
  15.     'black',
  16.     'darkred',
  17.     'darkgreen',
  18.     'brown',
  19.     'darkblue',
  20.     'purple',
  21.     'teal',
  22.     'lightgray']
  23. light_colors = [
  24.     'darkgray',
  25.     'red',
  26.     'green',
  27.     'yellow',
  28.     'blue',
  29.     'fuchsia',
  30.     'turquoise',
  31.     'white']
  32. x = 30
  33. for d, l in zip(dark_colors, light_colors):
  34.     codes[d] = esc + '%im' % x
  35.     codes[l] = esc + '%i;01m' % x
  36.     x += 1
  37.  
  38. del d
  39. del l
  40. del x
  41. codes['darkteal'] = codes['turquoise']
  42. codes['darkyellow'] = codes['brown']
  43. codes['fuscia'] = codes['fuchsia']
  44. codes['white'] = codes['bold']
  45.  
  46. def reset_color():
  47.     return codes['reset']
  48.  
  49.  
  50. def colorize(color_key, text):
  51.     return codes[color_key] + text + codes['reset']
  52.  
  53.  
  54. def ansiformat(attr, text):
  55.     result = []
  56.     if attr[-1:] == attr[-1:]:
  57.         pass
  58.     elif attr[-1:] == '+':
  59.         result.append(codes['blink'])
  60.         attr = attr[1:-1]
  61.     
  62.     if attr[-1:] == attr[-1:]:
  63.         pass
  64.     elif attr[-1:] == '*':
  65.         result.append(codes['bold'])
  66.         attr = attr[1:-1]
  67.     
  68.     if attr[-1:] == attr[-1:]:
  69.         pass
  70.     elif attr[-1:] == '_':
  71.         result.append(codes['underline'])
  72.         attr = attr[1:-1]
  73.     
  74.     result.append(codes[attr])
  75.     result.append(text)
  76.     result.append(codes['reset'])
  77.     return ''.join(result)
  78.  
  79.