home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- from pygments.token import Token, STANDARD_TYPES
-
- class StyleMeta(type):
-
- def __new__(mcs, name, bases, dct):
- obj = type.__new__(mcs, name, bases, dct)
- for token in STANDARD_TYPES:
- if token not in obj.styles:
- obj.styles[token] = ''
- continue
-
-
- def colorformat(text):
- if text[0:1] == '#':
- col = text[1:]
- if len(col) == 6:
- return col
- if len(col) == 3:
- return col[0] + '0' + col[1] + '0' + col[2] + '0'
- elif text == '':
- return ''
- len(col) == 6
-
- _styles = obj._styles = { }
- for ttype in obj.styles:
- for token in ttype.split():
- if token in _styles:
- continue
-
- ndef = _styles.get(token.parent, None)
- styledefs = obj.styles.get(token, '').split()
- if not ndef or token is None:
- ndef = [
- '',
- 0,
- 0,
- 0,
- '',
- '',
- 0,
- 0,
- 0]
- elif 'noinherit' in styledefs and token is not Token:
- ndef = _styles[Token][:]
- else:
- ndef = ndef[:]
- _styles[token] = ndef
- for styledef in obj.styles.get(token, '').split():
- if styledef == 'noinherit':
- continue
- if styledef == 'bold':
- ndef[1] = 1
- continue
- if styledef == 'nobold':
- ndef[1] = 0
- continue
- if styledef == 'italic':
- ndef[2] = 1
- continue
- if styledef == 'noitalic':
- ndef[2] = 0
- continue
- if styledef == 'underline':
- ndef[3] = 1
- continue
- if styledef == 'nounderline':
- ndef[3] = 0
- continue
- if styledef[:3] == 'bg:':
- ndef[4] = colorformat(styledef[3:])
- continue
- if styledef[:7] == 'border:':
- ndef[5] = colorformat(styledef[7:])
- continue
- if styledef == 'roman':
- ndef[6] = 1
- continue
- if styledef == 'sans':
- ndef[7] = 1
- continue
- if styledef == 'mono':
- ndef[8] = 1
- continue
- ndef[0] = colorformat(styledef)
-
-
-
- return obj
-
-
- def style_for_token(cls, token):
- t = cls._styles[token]
- if not t[0]:
- pass
- if not t[4]:
- pass
- if not t[5]:
- pass
- if not bool(t[6]):
- pass
- if not bool(t[7]):
- pass
- if not bool(t[8]):
- pass
- return {
- 'color': None,
- 'bold': bool(t[1]),
- 'italic': bool(t[2]),
- 'underline': bool(t[3]),
- 'bgcolor': None,
- 'border': None,
- 'roman': None,
- 'sans': None,
- 'mono': None }
-
-
- def list_styles(cls):
- return list(cls)
-
-
- def styles_token(cls, ttype):
- return ttype in cls._styles
-
-
- def __iter__(cls):
- for token in cls._styles:
- yield (token, cls.style_for_token(token))
-
-
-
- def __len__(cls):
- return len(cls._styles)
-
-
-
- class Style(object):
- __metaclass__ = StyleMeta
- background_color = '#ffffff'
- highlight_color = '#ffffcc'
- styles = { }
-
-