home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.5)
-
- from __future__ import with_statement
- import re
- from gui import skin
- from common import pref
- from path import path
- from util import traceguard, memoize
- from traceback import print_exc
- from contextlib import contextmanager
- from logging import getLogger
- log = getLogger('msgstyles')
-
- class MessageStyle(object):
-
- def should_always_show_timestamp(self):
- return getattr(self, '_ignore_show_tstamp_flag', False)
-
- should_always_show_timestamp = property(should_always_show_timestamp)
-
- def set_always_show_timestamp(self, val):
- self._ignore_show_tstamp_flag = val
-
-
-
- class MessageStyleException(Exception):
- pass
-
- CONVO_THEME_DIR = 'MessageStyles'
- msgStyleTypes = { }
-
- def register_message_style_type(name, constructor):
- msgStyleTypes[name] = constructor
-
-
- def get_user_themes_dirs():
- import stdpaths
- dirs = []
- for user_themes_dir in (stdpaths.userdata / CONVO_THEME_DIR, stdpaths.config / CONVO_THEME_DIR):
- traceguard.__enter__()
-
- try:
- if not user_themes_dir.isdir():
- user_themes_dir.makedirs()
- finally:
- pass
-
- dirs.append(user_themes_dir)
-
- return dirs
-
-
- def get_themes():
- p = skin.resourcedir() / CONVO_THEME_DIR
- themes = []
- userdirs = get_user_themes_dirs()
- userthemes = []
- for dir in userdirs:
- userdir = dir.abspath()
-
- try:
- None(userthemes.extend((lambda .0: for pth in .0:
- pth.abspath()) if userdir.exists() else []))
- continue
- except Exception:
- e = None
- print_exc()
- continue
-
-
-
- systemthemes = p.dirs()
- subdirs = userthemes + systemthemes
- for subdir in subdirs:
- ext = subdir.ext[1:]
- if ext in msgStyleTypes:
- traceguard.__enter__()
-
- try:
- themes.append(msgStyleTypes[ext](subdir.abspath()))
- finally:
- pass
-
- continue
- traceguard
-
- return themes
-
- get_themes = memoize(get_themes)
-
- def get_theme(name, variant = None):
- for theme in get_themes():
- if theme.theme_name == name:
- theme.variant = variant
- return theme
- continue
-
- raise MessageStyleException('theme "%s" not found' % name)
-
-
- def get_theme_safe(name, variant = None):
-
- try:
- return get_theme(name, variant)
- except Exception:
- print_exc()
-
- BasicMessageStyle = BasicMessageStyle
- import basicmsgstyle
- return BasicMessageStyle()
-
-