예제 #1
0
파일: renderers.py 프로젝트: sgricci/digsby
from time import time
from logging import getLogger; log = getLogger('renderers'); info = log.info
from common import pref, prefprop
import hooks


from gui import skin
from gui.skin.skinobjects import SkinColor, Margins
syscol = lambda s: SkinColor(SystemSettings_GetColour(s))

from PIL import Image

from traceback import print_exc
import sys

replace_newlines = lru_cache(100)(strings.replace_newlines)

def contact_online(contact):
    'Whether to display a buddy as online or not in the buddylist.'

    return contact.online or contact.status == 'mobile'

def get_contact_status(contact):
    if not contact_online(contact):
        return ''

    msg = hooks.reduce('digsby.status.tagging.strip_tag', contact.stripped_msg, contact.status, impl='text')
    if msg is not None:
        return replace_newlines(msg)

    return ''
예제 #2
0
'''

history support for text ctrls

ctrl+up   -> older
ctrl+down -> newer

TODO: use util.fmtstr and textctrl.GetFormattedValue to preserve formatting

'''
import wx
from util import strip_html2
from util.primitives.structures import roset
from util.lrucache import lru_cache

strip_html2 = lru_cache(80)(strip_html2)


class TextHistory(object):
    def __init__(self, ctrl = None, backlog = None):

        self.history = roset()
        self.clip    = ''
        self.index   = 0
        self.backlog = backlog

        if ctrl is not None:
            self.bind_textctrl(ctrl)

    def commit(self, val):
        if not val: return
예제 #3
0
파일: emailobj.py 프로젝트: niterain/digsby
from util import autoassign, strip_html_and_tags, replace_newlines, Storage
from util.lrucache import lru_cache
from util.auxencodings import fuzzydecode
from email.utils import parseaddr, parsedate
from email.header import decode_header
from datetime import datetime
import email.message
from common import pref
import sys, traceback

import logging

log = logging.getLogger("emailobj")

replace_newlines = lru_cache(100)(replace_newlines)

UnicodeErrors = (UnicodeEncodeError, UnicodeDecodeError)


def unicode_hdr(hdr, fallback=None):
    more_encs = [fallback] if fallback else []
    try:
        return u"".join(
            fuzzydecode(hdr, [encoding] + more_encs) if encoding else hdr for (hdr, encoding) in decode_header(hdr)
        )
    except UnicodeErrors:
        # a unicode string with extended ascii characters gets into this function, this is what happens
        # because the stdlib's decode_header function calls str() on its argument.
        return fuzzydecode(hdr, more_encs + ["utf-8"])
    except Exception:
예제 #4
0
'''

history support for text ctrls

ctrl+up   -> older
ctrl+down -> newer

TODO: use util.fmtstr and textctrl.GetFormattedValue to preserve formatting

'''
import wx
from util import strip_html2
from util.primitives.structures import roset
from util.lrucache import lru_cache

strip_html2 = lru_cache(80)(strip_html2)


class TextHistory(object):
    def __init__(self, ctrl=None, backlog=None):

        self.history = roset()
        self.clip = ''
        self.index = 0
        self.backlog = backlog

        if ctrl is not None:
            self.bind_textctrl(ctrl)

    def commit(self, val):
        if not val: return
예제 #5
0
from util import autoassign, strip_html_and_tags, replace_newlines, Storage
from util.lrucache import lru_cache
from util.auxencodings import fuzzydecode
from email.utils import parseaddr, parsedate
from email.header import decode_header
from datetime import datetime
import email.message
from common import pref
import sys, traceback

import logging

log = logging.getLogger('emailobj')

replace_newlines = lru_cache(100)(replace_newlines)

UnicodeErrors = (UnicodeEncodeError, UnicodeDecodeError)


def unicode_hdr(hdr, fallback=None):
    more_encs = [fallback] if fallback else []
    try:
        return u''.join(
            fuzzydecode(hdr, [
                encoding,
            ] + more_encs) if encoding else hdr
            for (hdr, encoding) in decode_header(hdr))
    except UnicodeErrors:
        # a unicode string with extended ascii characters gets into this function, this is what happens
        # because the stdlib's decode_header function calls str() on its argument.