コード例 #1
0
def htmlize_tweets(protocol, tweets, self_tweet=None):
    '''Given a protocol and a sequence of tweets, returns infobox HTML for them.'''

    t = TwitterIB(Storage(twitter_protocol=protocol, protocol='twitter'))
    return t.get_html(None,
                      set_dirty=False,
                      file='tweets.tenjin',
                      dir=t.get_context()['app'].get_res_dir('base'),
                      context=Storage(tweets=tweets, self_tweet=self_tweet))
コード例 #2
0
ファイル: roomlist.py プロジェクト: sgricci/digsby
    def __init__(self, *a, **k):
        wx.VListBox.__init__(self, *a, **k)
        syscol = wx.SystemSettings.GetColour

        self.colors = Storage(
            textfg=Storage(selected=syscol(wx.SYS_COLOUR_HIGHLIGHTTEXT),
                           normal=syscol(wx.SYS_COLOUR_WINDOWTEXT)))

        self.bg = Storage(selected=SkinColor(syscol(wx.SYS_COLOUR_HIGHLIGHT)),
                          normal=SkinColor(syscol(wx.SYS_COLOUR_LISTBOX)))

        self.fonts = Storage(text=default_font())

        self.BBind(LEFT_DOWN=self._OnLeftDown)
コード例 #3
0
    def __init__(self, username, password):
        self.username = username
        self.password = password

        self.recent_timeline = []
        self.self_tweet = None
        self.trends = {}

        self.feeds = []
        self.feeds_by_name = {}
        self.unread_counts = []

        e = self.events = Storage(
            (name, Delegate()) for name in self.event_names)

        e.following += self.on_following
        e.trends += self.on_trends
        e.on_unread_counts += self.on_unread_counts
        e.recent_timeline += self.on_recent_timeline
        e.self_tweet += self.on_self_tweet
        e.on_feeds += self.on_feeds
        e.on_change_view += self.on_change_view
        e.on_view += self.on_view_changed

        def render_tweets(tweets, render_context):
            return htmlize_tweets(self, tweets)

        self.social_feed = SocialFeed('twitter_' + self.username,
                                      'twitter_' + self.username,
                                      self.get_tweet_feed, render_tweets,
                                      lambda: self.account.set_infobox_dirty)
コード例 #4
0
ファイル: MSNP13Notification.py プロジェクト: sgricci/digsby
def zsiparse(soap, locatorname, name, raw):
    loc = getattr(soap, '%sLocator' % locatorname)()
    port = getattr(loc, 'get%sPort' % name)()
    binding = port.binding

    binding.reply_headers = Storage(type='text/xml')
    binding.data = raw
    return binding.Receive(getattr(soap,'%sResponseMessage' % name).typecode)
コード例 #5
0
ファイル: buddylistframe.py プロジェクト: sgricci/digsby
    def gui_layout(self, layoutNow=True):
        assert wx.IsMainThread()

        elems = ['status', 'blist', 'clist', 'slist', 'elist']

        searching = self.Searching
        panel_order = pref('buddylist.order', elems)
        email_view = pref('buddylist.show_email_as',
                          'panel') in ('panel', 'both') and len(
                              self.elist.active)
        social_view = pref('buddylist.show_social_as',
                           'panel') in ('panel', 'both') and len(
                               self.slist.active)
        status_view = searching or pref('buddylist.show_status', True)

        viewable = Storage()

        with self.Frozen():
            self.Sizer.Clear()  # remove all children, but don't delete.

            show_menu = pref('buddylist.show_menubar', True)
            if not config.platform == 'mac':
                if show_menu:
                    self.Sizer.Add(self.menubar.SizableWindow, 0, EXPAND)

                self.menubar.Show(show_menu)

            if searching or (hasattr(self, 'status') and status_view):
                viewable.status = (self.status, 0, EXPAND)

            viewable.blist = (self.blist, 1, EXPAND)
            viewable.clist = (self.clist, 0, EXPAND)

            if email_view:
                viewable.elist = (self.elist, 0, EXPAND)

            if social_view:
                viewable.slist = (self.slist, 0, EXPAND)

            AddInOrder(self.Sizer, *panel_order, **viewable)

            self.status.Show(status_view)
            self.elist.Show(email_view)
            self.slist.Show(social_view)

            if layoutNow:
                self.Layout()
コード例 #6
0
ファイル: MSNP13Notification.py プロジェクト: sgricci/digsby
    def ABGroupAddError(self, request, result, exc, gname):
        if get_fault(exc) == 'GroupAlreadyExists':
            detail = exc.fault.detail
            gid = None
            try:
                gid = detail[3]['conflictObjectId']
            except (AttributeError, KeyError):
                log.info('Couldn\'t get conflict ID, here\'s the detail: %r', detail)

            if gid is not None:
                return self.ABGroupAddSuccess(request, Storage(Guid=gid), gname)
            else:
                raise exc
        else:
            raise exc


        '''
コード例 #7
0
def fileinfo(filepath):
    'Collect information about a file or directory for sending it.'

    filestats = os.stat(filepath)

    # create a storage with meta information about the file.
    s = Storage(
        size=os.path.getsize(filepath),
        modtime=filestats[stat.ST_MTIME],
        ctime=filestats[stat.ST_CTIME],
        name=os.path.split(filepath)[1],
        path=path(filepath),
    )

    if os.path.isdir(filepath):
        # directories have all the above information, and
        # files, a list of path objects
        s.type = 'dir'

        s.size = s.numfiles = 0
        s.files = []
        s.path = path(filepath)

        for f in path(filepath).walkfiles():
            s.size += f.size  # accumulate size,
            s.numfiles += 1  # and number,
            s.files.append(f)  # and a list of names

        info('sending folder with %d files (%d bytes)', s.numfiles, s.size)
    else:
        s.type = 'file'
        s.obj = open(filepath, 'rb')
        s.numfiles = 1
        s.files = [path(filepath)]

    return s
コード例 #8
0
def GetBuddies(id):
    acctdir = id['logdir'] / id['proto'] / id['acct']
    buddies = []
    aliases = IAliasProvider(profile())
    for bdir in acctdir.dirs():
        try:
            name, service = bdir.name.rsplit('_', 1)
            serviceicon = skin.get('serviceicons.'+service,None).ResizedSmaller(16)
        except Exception:
            continue
        buddies.append(Storage(icon = serviceicon,
                               name = name,
                               alias = aliases.get_alias(name.lower(), service, acctdir.parent.name) or name,
                               protocol = acctdir.parent.name,
                               service = service,
                               dir = bdir))

    buddies.sort(key=lambda s: s.alias.lower())

    return buddies
コード例 #9
0
ファイル: Buddy.py プロジェクト: AlexUlrich/digsby
def fileinfo(filepath):
    'Collect information about a file or directory for sending it.'

    filestats = os.stat(filepath)

    # create a storage with meta information about the file.
    s = Storage(
        size    = os.path.getsize(filepath),
        modtime = filestats[stat.ST_MTIME],
        ctime   = filestats[stat.ST_CTIME],
        name    = os.path.split(filepath)[1],
        path    = path(filepath),
    )

    if os.path.isdir(filepath):
        # directories have all the above information, and
        # files, a list of path objects
        s.type = 'dir'

        s.size = s.numfiles = 0
        s.files = []
        s.path = path(filepath)

        for f in path(filepath).walkfiles():
            s.size  += f.size         # accumulate size,
            s.numfiles += 1           # and number,
            s.files.append(f)    # and a list of names

        info('sending folder with %d files (%d bytes)', s.numfiles, s.size)
    else:
        s.type = 'file'
        s.obj  = open(filepath, 'rb')
        s.numfiles = 1
        s.files = [path(filepath)]

    return s
コード例 #10
0
ファイル: buddylistframe.py プロジェクト: AlexUlrich/digsby
    def gui_layout(self, layoutNow = True):
        assert wx.IsMainThread()

        elems = ['status', 'blist','clist', 'slist', 'elist']

        searching   = self.Searching
        panel_order = pref('buddylist.order', elems)
        email_view  = pref('buddylist.show_email_as', 'panel') in ('panel', 'both') and len(self.elist.active)
        social_view = pref('buddylist.show_social_as', 'panel') in ('panel', 'both') and len(self.slist.active)
        status_view = searching or pref('buddylist.show_status', True)

        viewable = Storage()

        with self.Frozen():
            self.Sizer.Clear() # remove all children, but don't delete.

            show_menu = pref('buddylist.show_menubar', True)
            if not config.platform == 'mac':
                if show_menu:
                    self.Sizer.Add(self.menubar.SizableWindow, 0, EXPAND)

                self.menubar.Show(show_menu)

            if searching or (hasattr(self, 'status') and status_view):
                viewable.status = (self.status,  0, EXPAND)

            viewable.blist =     (self.blist,   1, EXPAND)
            viewable.clist =     (self.clist,   0, EXPAND)

            if email_view:
                viewable.elist = (self.elist,   0, EXPAND)

            if social_view:
                viewable.slist = (self.slist,   0, EXPAND)

            AddInOrder(self.Sizer, *panel_order, **viewable)

            self.status.Show(status_view)
            self.elist.Show(email_view)
            self.slist.Show(social_view)

            if layoutNow:
                self.Layout()
コード例 #11
0
ファイル: SplitImage2.py プロジェクト: sgricci/digsby
    def __init__(self, image_dict):
        '''
        Sets up this image, splitting what is necessary and preparing the cache.

        @param image_dict: a descriptive dictionary for how to load and draw
        this image it is probably a good idea to pass in a copy if this
        dictionary will be used elsewhere.
        '''
        imgs = self.image_dictionary = to_storage(image_dict)
        image = skin.load_image(imgs.source)
        self.cache = Storage()

        clipcolor = imgs.get('clipcolor', None)
        if clipcolor is not None:
            self.cache.clipcolor = get_wxColor(imgs.clipcolor)
            image.SetMask(wx.Mask(image, self.cache.clipcolor))

        imgw = image.GetWidth()
        self.imgw = imgw
        imgh = image.GetHeight()
        self.imgh = imgh
        self.draw_commands = []
        #if corners exit
        if imgs.corners:
            self.regions_to_draw = None
            cornw = imgs.cornw = imgs.corners.size[0]
            cornh = imgs.cornh = imgs.corners.size[1]
            #else:
            #do 4-section magic
            #not really! just 2 sections, corners just drawn
            if imgs.corners.side == 'left':
                self.corners_to_draw = ['top_left', 'bottom_left']
                #cache big right
                if imgw - cornw > 0:
                    self.cache.large_right = \
                    image.GetSubBitmap(wx.Rect(cornw, 0, imgw - cornw, imgh))
                    self.regions_to_draw = ['left', 'large_right']
                else:
                    self.regions_to_draw = ['left']
                #stretch the right from x pixels off
            elif imgs.corners.side == 'right':
                self.corners_to_draw = ['top_right', 'bottom_right']
                if imgw - cornw > 0:
                    self.cache.large_left = \
                    image.GetSubBitmap(wx.Rect(0, 0, imgw - cornw, imgh))
                    self.regions_to_draw = ['large_left', 'right']
                else:
                    self.regions_to_draw = ['right']
            elif imgs.corners.side == 'top':
                self.corners_to_draw = ['top_left', 'top_right']
                if imgh - cornh > 0:
                    self.cache.large_bottom = \
                    image.GetSubBitmap(wx.Rect(0, cornh, imgw, imgh - cornh))
                    self.regions_to_draw = ['top', 'large_bottom']
                else:
                    self.regions_to_draw = ['top']
            elif imgs.corners.side == 'bottom':
                self.corners_to_draw = ['bottom_left', 'bottom_right']
                if imgh - cornh > 0:
                    self.cache.large_top = \
                    image.GetSubBitmap(wx.Rect(0, 0, imgw, imgh - cornh))
                    self.regions_to_draw = ['large_top', 'bottom']
                else:
                    self.regions_to_draw = ['bottom']
            #if all corners:
            #else if image.corners.side == 'all':
            else:
                #go do 9-section magic
                #not really! just 5 sections, corners just drawn
                self.corners_to_draw = [
                    'top_left', 'top_right', 'bottom_left', 'bottom_right'
                ]
                self.regions_to_draw = [
                    'left', 'right', 'top', 'bottom', 'center'
                ]

            [
                self.draw_commands.append(
                    (getattr(self, 'draw_' + corner + '_corner'), None))
                for corner in self.corners_to_draw
            ]
            if 'top_left' in self.corners_to_draw:
                #cache this corner
                self.cache.top_left = \
                image.GetSubBitmap(wx.Rect(0, 0, cornw, cornh))
            if 'top_right' in self.corners_to_draw:
                self.cache.top_right = \
                image.GetSubBitmap(wx.Rect(imgw - cornw, 0, cornw, cornh))
            if 'bottom_left' in self.corners_to_draw:
                self.cache.bottom_left = \
                image.GetSubBitmap(wx.Rect(0, imgh - cornh, cornw, cornh))
            if 'bottom_right' in self.corners_to_draw:
                self.cache.bottom_right = \
                image.GetSubBitmap(wx.Rect(imgw - cornw, imgh - cornh, cornw, cornh))
            if 'left' in self.regions_to_draw:
                self.cache.left = \
                image.GetSubBitmap(wx.Rect(0, cornh, cornw, imgh - cornh*2))
            if 'right' in self.regions_to_draw:
                self.cache.right = \
                image.GetSubBitmap(wx.Rect(imgw - cornw, cornh, cornw, imgh - cornh*2))
            if 'top' in self.regions_to_draw:
                self.cache.top = \
                image.GetSubBitmap(wx.Rect(cornw, 0, imgw - cornw*2, cornh))
            if 'bottom' in self.regions_to_draw:
                self.cache.bottom = \
                image.GetSubBitmap(wx.Rect(cornw, imgh - cornh, imgw - cornw*2, cornh))
            if 'center' in self.regions_to_draw:
                self.cache.center = \
                image.GetSubBitmap(wx.Rect(cornw, cornh, imgw - cornw*2, imgh - cornh*2))
        else:
            #default (stretch/tile) everything
            self.cache.total = image
            #no - assert(image.style == 'stretch' or image.style == 'tile')
            self.cache["totalch"] = 'left'
            self.cache["totalcv"] = 'top'
            self.cache["totalco"] = [0, 0]
            self.regions_to_draw = ["total"]
            #image.style to everything
        for region in self.regions_to_draw:
            if region in self.image_dictionary.regions:
                region_dict = self.image_dictionary.regions[region]
                style = region_dict['style']
                self.draw_commands.append((getattr(self,
                                                   'draw_' + region), style))
                if style == 'static' or self.image_dictionary.style == 'static':
                    color = get_wxColor(region_dict['color'])
                    if color is not None:
                        self.cache[region + "cb"] = wx.Brush(color)
                    else:
                        self.cache[region + "cb"] = None
                    self.cache[region + "ch"] = region_dict['halign']
                    self.cache[region + "cv"] = region_dict['valign']
                    self.cache[region + "co"] = region_dict['offset']
            else:
                self.draw_commands.append((getattr(self, 'draw_' + region),
                                           self.image_dictionary['style']))
コード例 #12
0
ファイル: SplitImage2.py プロジェクト: sgricci/digsby
        self.dc = dc
        self.rect = rect
        self.rs = []
        do(func(args) for (func, args) in self.draw_commands)
        self.region = wx.Region(0, 0, 0, 0)
        for region in self.rs:
            if not region.IsEmpty():
                self.region.UnionRegion(region)
        self.dc = None
        self.rect = None


if __name__ == '__main__':
    from skins import images, skins
    app = wx.PySimpleApp()
    image = Storage()
    image['style'] = 'static'
    image['source'] = 'skins/default/checkerboard9.png'
    #    image['clipcolor'] = '0xFF00DD'
    image['corners'] = {}
    #    image['corners']['size'] = [10,10]
    #    image['corners']['side'] = 'none'
    image['halign'] = 'left'
    image['valign'] = 'top'
    image['offset'] = [50, 50]
    image['regions'] = dict(center=dict(style='static',
                                        color='red',
                                        valign='center',
                                        halign='center',
                                        offset=[50, 50]))
    skins.res_path = "res/"
コード例 #13
0
ファイル: buddylistframe.py プロジェクト: sgricci/digsby
    def __init__(self, parent=None):
        SimplePanel.__init__(self, parent)
        self.Sizer = wx.BoxSizer(wx.VERTICAL)

        link = profile.prefs.link  #@UndefinedVariable

        # setup and layout GUI
        self.tray_icons = []
        self.gui_construct()
        rebuild = self.rebuild_panels
        rebuild()

        # Watch always on top changes
        def ontop_changed(val):
            docker = wx.GetTopLevelParent(self).docker
            if docker.docked and docker.AutoHide:
                return

            p = wx.GetTopLevelParent(self)
            if val: p.WindowStyle = p.WindowStyle | wx.STAY_ON_TOP
            else: p.WindowStyle = p.WindowStyle & ~wx.STAY_ON_TOP

        self.unlinkers = [
            link(*a)
            for a in [(
                'buddylist.always_on_top', ontop_changed, True, self
            ), ('buddylist.order', lambda v: self.gui_layout(), False,
                self), ('buddylist.show_status', rebuild,
                        False), (
                            'buddylist.show_email_as', rebuild,
                            False), ('buddylist.show_social_as', rebuild,
                                     False),
                      ('buddylist.show_menubar', lambda v: self.gui_layout(),
                       False,
                       self), ('social.display_attr', rebuild,
                               False), ('email.display_attr', rebuild, False),
                      ('buddylist.show_in_taskbar',
                       lambda val: wx.CallAfter(lambda: setattr(
                           self.Top, 'OnTaskbar', val)), True, self)]
        ]

        # link docking preferences
        link = profile.localprefs.link
        docker = wx.GetTopLevelParent(self).docker

        self.unlinkers += [
            link(*a) for a in [
                ('buddylist.dock.autohide',
                 lambda v: docker.SetAutoHide(bool(v)), True, docker),
                ('buddylist.dock.enabled',
                 lambda v: docker.SetEnabled(bool(v)), True, docker),
                ('buddylist.dock.revealms', lambda v: setattr(
                    docker, 'RevealDurationMs', try_this(lambda: int(v), 300)),
                 True, docker),
            ]
        ]

        self.unlinkers.append(
            profile.prefs.link(
                'buddylist.dock.slide_velocity',
                lambda v: wx.CallAfter(docker.SetVelocity, int(v)),
                obj=docker))  #@UndefinedVariable
        self.unlinkers.append(
            Storage(unlink=profile.emailaccounts.add_list_observer(
                rebuild, rebuild, 'enabled').disconnect))
        self.unlinkers.append(
            Storage(unlink=profile.socialaccounts.add_list_observer(
                rebuild, rebuild, 'enabled').disconnect))

        # don't ever let this control take focus
        self.Bind(wx.EVT_SET_FOCUS, lambda e: self.blist.SetFocus())
コード例 #14
0
def init_wx(appname='Digsby'):
    if config.platform != 'win':
        # on windows we don't use wxStandardPaths at all to avoid having to have
        # the app created.
        return init_wx_old()

    paths = \
    [('GetConfigDir', CSIDL.COMMON_APPDATA, True),
     ('GetDataDir', GetAppDir),
     ('GetDocumentsDir', CSIDL.PERSONAL, False),
     ('GetExecutablePath', lambda: sys.executable),
     ('GetLocalDataDir', GetAppDir),

     ('GetUserConfigDir', CSIDL.APPDATA, False),
     ('GetUserDataDir', CSIDL.APPDATA, True),
     ('GetUserLocalDataDir', CSIDL.LOCAL_APPDATA, True),
     ('GetUserLocalConfigDir', CSIDL.LOCAL_APPDATA, False),
     ('GetTempDir', GetTempDir)
     ]

    from util.primitives.mapping import Storage
    s = Storage()

    for p in paths:
        name = p[0]
        if hasattr(p[1], '__call__'):
            s[name] = p[1]
        else:
            csidl, append_app_name = p[1], p[2]
            if append_app_name:
                method = lambda id=csidl: GetFolderLocation(id) + '\\' + appname
            else:
                method = lambda id=csidl: GetFolderLocation(id)

            setattr(s, name, method)

    paths_dict = dict(config = s.GetConfigDir(),
                      data   = s.GetDataDir(),
                      documents = s.GetDocumentsDir(),
                      executablepath = s.GetExecutablePath(),
                      localdata = s.GetLocalDataDir(),

                      userconfig = s.GetUserConfigDir(),
                      userdata = s.GetUserDataDir(),
                      userlocaldata = s.GetUserLocalDataDir(),
                      userlocalconfig = s.GetUserLocalConfigDir(),

                      temp = s.GetTempDir())

    _winpaths = [
        ('GetUserStartupDir', CSIDL.STARTUP),
        ('GetStartupDir',     CSIDL.COMMON_STARTUP),
        ('GetUserDesktopDir', CSIDL.DESKTOP),
        ('GetDesktopDir',     CSIDL.COMMON_DESKTOPDIRECTORY)
    ]

    for method_name, csidl in _winpaths:
        setattr(s, method_name, lambda id=csidl: GetFolderLocation(id))

    # extended wxStandardPaths folders
    paths_dict.update(userstartup = s.GetUserStartupDir(),
                      startup = s.GetStartupDir(),
                      userdesktop = s.GetUserDesktopDir(),
                      desktop = s.GetDesktopDir())

    _set_paths(**paths_dict)
    return paths_dict
コード例 #15
0
ファイル: OscarBuddies.py プロジェクト: sgricci/digsby
from util.primitives.strings import dequote, preserve_whitespace, strip_html2

from traceback import print_exc

strip_html2 = lru_cache(80)(strip_html2)

import re
body_pattern = re.compile('<(body|BODY)[^>]*?((bgcolor|BGCOLOR)=(.*?))? ?>')
font_back_pattern = re.compile('<(font|FONT)[^>]*?((back|BACK)=\s*[\'"]?(#[0-f]{6})[\'"]?).*?>')
blast_group_re = re.compile(r'\[.*\]')

import oscar.capabilities

statuses=Storage({
    'free for chat':_('Free for Chat'),
    'busy':_('Occupied'),
    'unknown': _('Offline'),
})

# used to replace special strings in statuses and profiles
special_msg_strings = {
    '%n': lambda buddy: buddy.protocol.username,
    '%d': lambda buddy: datetime.date.today().strftime('%m/%d/%Y'), # 3/7/2007
    '%t': lambda buddy: datetime.datetime.now().strftime('%I:%M:%S %p') #12:20:07 PM
}

def magic_string_repl(s, buddy):
    # TODO: re.replace
    for key, substitute_func in special_msg_strings.iteritems():
        if key in s:
            s = s.replace(key, substitute_func(buddy))