Ejemplo n.º 1
0
    def authorize_token(self, callback = None):

        if self.OPENID:
            params = util.odict((
                                 ('myspaceid.consumer_key',   self.consumer.key),
                                 ('openid.oauth.consumer',    self.consumer.key),
                                 ('openid.mode',              'checkid_setup'),
                                 ('openid.realm',             'http://www.digsby.com/'),
                                 ('myspaceid.target_domain',  'http://www.digsby.com/myspace/'),
                                 ('openid.return_to',         'http://www.digsby.com/myspace/'),
                                 ('openid.ns',                'http://specs.openid.net/auth/2.0'),
                                 ('openid.ns.oauth',          'http://specs.openid.net/extensions/oauth/1.0'),
                                 ('openid.claimed_id',        'http://specs.openid.net/auth/2.0/identifier_select'),
                                 ('openid.identity',          'http://specs.openid.net/auth/2.0/identifier_select'),
                                 ('myspaceid.permissions',    '|'.join(self.required_permissions))
                               ))
        else:
            params = util.odict((
                                 ('myspaceid.consumer_key',   self.consumer.key),
                                 ('myspaceid.target_domain',  'http://www.digsby.com/myspace/'),
                                 ('myspaceid.permissions',    '|'.join(self.required_permissions))
                               ))

        callback_url_function = lambda cb_url: self.RequestFactory(
                                                   net.UrlQuery(self.urls['request_token'], params),
                                                   openid_req = self.OPENID,
                                                   ).get_full_url()

        self.event("open_oauth_page", callback_url_function, callback)
Ejemplo n.º 2
0
    def authorize_token(self, callback=None):

        if self.OPENID:
            params = util.odict(
                (('myspaceid.consumer_key',
                  self.consumer.key), ('openid.oauth.consumer',
                                       self.consumer.key),
                 ('openid.mode', 'checkid_setup'), ('openid.realm',
                                                    'http://www.digsby.com/'),
                 ('myspaceid.target_domain', 'http://www.digsby.com/myspace/'),
                 ('openid.return_to', 'http://www.digsby.com/myspace/'),
                 ('openid.ns', 'http://specs.openid.net/auth/2.0'),
                 ('openid.ns.oauth',
                  'http://specs.openid.net/extensions/oauth/1.0'),
                 ('openid.claimed_id',
                  'http://specs.openid.net/auth/2.0/identifier_select'),
                 ('openid.identity',
                  'http://specs.openid.net/auth/2.0/identifier_select'),
                 ('myspaceid.permissions',
                  '|'.join(self.required_permissions))))
        else:
            params = util.odict(
                (('myspaceid.consumer_key', self.consumer.key),
                 ('myspaceid.target_domain', 'http://www.digsby.com/myspace/'),
                 ('myspaceid.permissions',
                  '|'.join(self.required_permissions))))

        callback_url_function = lambda cb_url: self.RequestFactory(
            net.UrlQuery(self.urls['request_token'], params),
            openid_req=self.OPENID,
        ).get_full_url()

        self.event("open_oauth_page", callback_url_function, callback)
Ejemplo n.º 3
0
    def load(self):

        dirs = [x for x in self.path.glob('*.emoticon') if x.isdir()]
        emoticons = odict()
        bitmaps = odict()
        title = self.path.name
        for dir in dirs:
            imgpath = dir / 'Emoticon.gif'
            if not imgpath.isfile():
                continue

            smileys_path = (dir / 'TextEquivalents.txt')
            if not smileys_path.isfile():
                continue

            smileys = smileys_path.lines()

            for smiley in smileys:
                smiley = smiley.strip()
                if not smiley:
                    continue

                emoticons[smiley] = S(path = imgpath)

                if not imgpath in bitmaps:
                    bitmaps[imgpath] = [smiley]
                else:
                    bitmaps[imgpath].append(smiley)

        self.name = title
        self.emoticons = emoticons
        self.bitmaps = bitmaps

        self.post_load()
Ejemplo n.º 4
0
    def load(self):
        emoticons_txt = self.path / 'Emoticons.plist'
        if not emoticons_txt.isfile():
            return None, None

        title = self.path.name
        with file(emoticons_txt) as f:
            plist = tag(f.read())
            toplevel = plist._children[0]
            converted = plisttype_to_pytype(toplevel)
            emoticons = odict()
            bitmaps = odict()

            for img_name, info in sorted(converted['Emoticons'].items()):
                smileys = info['Equivalents']
                imgpath = self.path / img_name
                if imgpath.isfile():
                    for smiley in smileys:
                        if not smiley:
                            continue # for badly formed plists with <string></string>

                        emoticons[smiley] = S(path = imgpath)
                        if not imgpath in bitmaps:
                            bitmaps[imgpath] = [smiley]
                        else:
                            bitmaps[imgpath].append(smiley)

        self.name = title
        self.emoticons = emoticons
        self.bitmaps = bitmaps

        self.post_load()
Ejemplo n.º 5
0
    def load(self):
        emoticons_txt = self.path / 'Emoticons.plist'
        if not emoticons_txt.isfile():
            return None, None

        title = self.path.name
        with file(emoticons_txt) as f:
            plist = tag(f.read())
            toplevel = plist._children[0]
            converted = plisttype_to_pytype(toplevel)
            emoticons = odict()
            bitmaps = odict()

            for img_name, info in sorted(converted['Emoticons'].items()):
                smileys = info['Equivalents']
                imgpath = self.path / img_name
                if imgpath.isfile():
                    for smiley in smileys:
                        if not smiley:
                            continue  # for badly formed plists with <string></string>

                        emoticons[smiley] = S(path=imgpath)
                        if not imgpath in bitmaps:
                            bitmaps[imgpath] = [smiley]
                        else:
                            bitmaps[imgpath].append(smiley)

        self.name = title
        self.emoticons = emoticons
        self.bitmaps = bitmaps

        self.post_load()
Ejemplo n.º 6
0
    def load(self):

        dirs = [x for x in self.path.glob('*.emoticon') if x.isdir()]
        emoticons = odict()
        bitmaps = odict()
        title = self.path.name
        for dir in dirs:
            imgpath = dir / 'Emoticon.gif'
            if not imgpath.isfile():
                continue

            smileys_path = (dir / 'TextEquivalents.txt')
            if not smileys_path.isfile():
                continue

            smileys = smileys_path.lines()

            for smiley in smileys:
                smiley = smiley.strip()
                if not smiley:
                    continue

                emoticons[smiley] = S(path=imgpath)

                if not imgpath in bitmaps:
                    bitmaps[imgpath] = [smiley]
                else:
                    bitmaps[imgpath].append(smiley)

        self.name = title
        self.emoticons = emoticons
        self.bitmaps = bitmaps

        self.post_load()
Ejemplo n.º 7
0
 def __init__(self, d = None, **kwds):
     object.__init__(self)
     if d is None:
         d = util.odict(**kwds)
     else:
         d = util.odict(d)
         d.update(kwds)
     self.dict = d
     self.orig_keys = dict((k.lower(), k) for k in self.dict)
Ejemplo n.º 8
0
    def pretty_profile(self):
        d = odict()

        import msn.AddressBook as MSNAB
        CPMR = MSNAB.CirclePersonalMembershipRole

        members = self.get_role_names(CPMR.Member)
        admins = self.get_role_names(CPMR.Admin)
        assistant_admins = self.get_role_names(CPMR.AssistantAdmin)
        pending = list(set(self.get_role_names(CPMR.StatePendingOutbound) +
                           self._get_invited_names() +
                           self.get_state_names(MSNAB.RelationshipStates.Left) +
                           self.get_state_names(MSNAB.RelationshipStates.WaitingResponse)))

        for name in pending:
            for _list in (members, admins, assistant_admins):
                if name in _list:
                    _list.remove(name)

        names_to_pp = lambda l: [['\n', name] for name in l] + ['\n']

        if admins:
            d[_('Administrators:')] = names_to_pp(admins)
        if assistant_admins:
            d[_('Assistant Administrators:')] = names_to_pp(assistant_admins)
        if members:
            d[_('Members:')] = names_to_pp(members or [_('(none)')])
        if pending:
            d[_('Invited:')] = names_to_pp(pending)

        return d
Ejemplo n.º 9
0
 def __init__(self, opts):
     self.opts = opts
     self.elementNameObjectMap = dict()
     self.objects = odict()
     self.parents = dict()
     # A mapping of abstract substitution groups with the abstract element
     self.substitutionElement_map = dict()
Ejemplo n.º 10
0
    def load(self):
        theme = self.path / 'theme'
        if not theme.isfile():
            return None, None

        smileys = defaultdict(list)
        emoticons = {}
        bitmaps = odict()
        title = self.path.name

        with file(theme) as f:
            for line in f:
                if line.count('\t') > 0:
                    seq = filter(None, line.strip().split('\t'))
                    if len(seq) >= 2:
                        img, smiley = seq[:2]
                        imgpath = self.path / img
                        if imgpath.isfile():
                            emoticons[smiley.encode('xml')] = S(path = imgpath)

                            if not imgpath in bitmaps:
                                bitmaps[imgpath] = [smiley]
                            else:
                                bitmaps[imgpath].append(smiley)
                elif line.count('='):
                    key, val = line.split('=', 1)
                    if key.lower() == 'name':
                        title = val

        self.name = title
        self.emoticons = emoticons
        self.bitmaps = bitmaps

        self.post_load()
Ejemplo n.º 11
0
    def load(self):
        theme = self.path / 'theme'
        if not theme.isfile():
            return None, None

        smileys = defaultdict(list)
        emoticons = {}
        bitmaps = odict()
        title = self.path.name

        with file(theme) as f:
            for line in f:
                if line.count('\t') > 0:
                    seq = filter(None, line.strip().split('\t'))
                    if len(seq) >= 2:
                        img, smiley = seq[:2]
                        imgpath = self.path / img
                        if imgpath.isfile():
                            emoticons[smiley.encode('xml')] = S(path=imgpath)

                            if not imgpath in bitmaps:
                                bitmaps[imgpath] = [smiley]
                            else:
                                bitmaps[imgpath].append(smiley)
                elif line.count('='):
                    key, val = line.split('=', 1)
                    if key.lower() == 'name':
                        title = val

        self.name = title
        self.emoticons = emoticons
        self.bitmaps = bitmaps

        self.post_load()
Ejemplo n.º 12
0
 def __init__(self, opts):
     self.opts = opts
     self.elementNameObjectMap = dict()
     self.objects = odict()
     self.parents = dict()
     # A mapping of abstract substitution groups with the abstract element
     self.substitutionElement_map = dict()
Ejemplo n.º 13
0
    def to_xml(self):
        #for attr in 'stamp avatarcontentid contenttype contentid avatarid'.split():
        #    val = getattr(self, attr)
        #    if val is not None:
        #        attrs[attr] = val

        if self._xml is None:

            # stupid libpurple doesnt know how to do XML.
            # so we have to put the attrs in the right order,
            # and we replace the " />" at the end with "/>".
            # note the missing space.

            t = util.xml_tag.tag('msnobj')
            t._attrs = util.odict()
            t._attrs['Creator'] = self.creator
            t._attrs['Size'] = self.size
            t._attrs['Type'] = self.type
            t._attrs['Location'] = self.location
            t._attrs['Friendly'] = self.friendly
            t._attrs['SHA1D'] = self.sha1d
            t._attrs['SHA1C'] = self.sha1c

            xml = t._to_xml(pretty=False).strip()
            xml = xml[:-3] + '/>'
            self._xml = xml

        return self._xml
Ejemplo n.º 14
0
 def start_loop(self):
     self.is_loop = True
     self.loop_start_time = time.time()
     self.last_loop_time = self.loop_start_time
     self.ticks = odict()
     log('profile %s: %0.2fs - START LOOP' %
         (self.name, time.time() - self.start_time))
Ejemplo n.º 15
0
    def __init__(self, s):
        str.__init__(s)
        info('Cookie string %s', s)
        self.params = odict()

        for pair in s.split('&'):
            key, val = pair.split('=')
            self.params[key] = val
Ejemplo n.º 16
0
    def __init__(self, s):
        str.__init__(s)
        info('Cookie string %s', s)
        self.params = odict()

        for pair in s.split('&'):
            key, val = pair.split('=')
            self.params[key] = val
Ejemplo n.º 17
0
def yiter_to_dict(yiter):
    d = odict()

    for k, v in yiter:
        try: k = ykeys[k]
        except KeyError: pass
        d[k] = v

    return d
Ejemplo n.º 18
0
def yiter_to_dict(yiter):
    d = odict()

    for k, v in yiter:
        try:
            k = ykeys[k]
        except KeyError:
            pass
        d[k] = v

    return d
Ejemplo n.º 19
0
def scrape_profile(s):
    # fixup HTML
    s = s.replace(u'&nbsp;', u' ').replace(u'Hobbies:</dd>', u'Hobbies:</dt>')
    soup = BeautifulStoneSoup(s, convertEntities=BeautifulStoneSoup.ALL_ENTITIES,
                              fromEncoding = 'utf-8')
    profile = odict()

    # grab info
    for section in ('basics', 'more'):
        div = soup('div', id='ypfl-' + section)[0].dl
        if div is not None:
            info = [elem.renderContents(None) for elem in div if elem != u'\n']
            profile.update(dictfrompairs(info))

    # grab links
    links = dictfrompairs([e.renderContents(None).replace('<em>','').replace('</em>','')
                           for e in soup('dl', attrs = {'class':'mylinks'})[0].contents if e != u'\n'])

    # construct [list of] tuples for links
    if 'Home Page:' in links: links['Home Page:'] = anchor2tuple(links['Home Page:'])
    linktuples = [anchor2tuple(v) for k, v in sorted(links.items())
                  if k.startswith('Cool Link')]

    # insert newlines between the link tuples.
    finallinks = []
    for i, tuple in enumerate(linktuples):
        finallinks.append(tuple)
        if i != len(linktuples) - 1: finallinks.append(u'\n')
    links['Links:'] = finallinks

    do(links.pop(k) for k in links.keys() if k.startswith('Cool Link'))

    profile.update(links)

    # pull "member since" and "last update"
    for p in soup.findAll('p', attrs = {'class':'footnote'}):
        c = p.renderContents(None)
        for hdr in ('Member Since ', 'Last Update: '):
            if c.startswith(hdr):
                profile[hdr] = c[len(hdr):]

    # remove empty entries
    for k, v in dict(profile).iteritems():
        if isinstance(v, basestring):
            dict.__setitem__(profile, k,
                             None if v.strip() in ('', 'No Answer') else scrape_clean(v))

    profile.pop('Yahoo! ID:', None)

    return profile
Ejemplo n.º 20
0
 def __init__(self, element, parent, model):
     self.model = model
     self.element = element
     self.parent = parent
     self.base = element.getBase()
     self.name = element.getName()
     self.type = element.getType()
     self.properties = odict()
     self.isAbstract = False
     self.isParentOrdered = False
     self.isChildOrdered = False
     self.isOrdered = False
     self.isUnique = False
     self.isImmutable = False
     self._isGlobal = False
     self.base in ('Annotation', 'BasicAnnotation') \
         or self.name == 'Annotation'
     self.plural = None
     self.manyToMany = False
     self.isAbstractSubstitution = self.model.opts.lang.hasSubstitutionGroup(
         self.name)
     self.isConcreteSubstitution = self.model.opts.lang.hasSubstitutionGroup(
         self.base)
     self.topLevelName = element.getName()
     self.hasPrimitiveBase = False
     if self.isConcreteSubstitution:
         self.topLevelName = self.base
     try:
         try:
             root = ElementTree.fromstring(element.appinfo)
         except:
             logging.error('Exception while parsing %r' % element.appinfo)
             raise
         if root.find('abstract') is not None:
             self.isAbstract = True
         if root.find('unique') is not None:
             self.isUnique = True
         if root.find('immutable') is not None:
             self.isImmutable = True
         if root.find('global') is not None:
             self._isGlobal = True
         if root.find('parentordered') is not None:
             self.isParentOrdered = True
         if root.find('childordered') is not None:
             self.isChildOrdered = True
         if root.find('ordered') is not None:
             self.isOrdered = True
         self.plural = root.findtext('plural')
     except AttributeError:
         pass
Ejemplo n.º 21
0
    def pretty_profile(self):
        #none = u'No Profile'
        if self.service != 'yahoo':
            return None

        if self.y360hash:
            p = odict(self.profile)

            now = time()
            filteredupdates = []

            for update_and_time in self.y360updates:
                try:
                    update, tstamp = update_and_time
                except:
                    continue
                if now - tstamp <= 60 * 60 * 24:
                    filteredupdates.append((update, tstamp))

            self.y360updates = filteredupdates

            ups = [u for u, t in self.y360updates]
            withnewlines = []
            if ups:
                for i, u in enumerate(ups):
                    withnewlines.append(u)
                    if i != len(ups) - 1: withnewlines.append('\n')
            else:
                withnewlines.append(_('No Updates'))

            from . import yahoo360
            profilelink = (yahoo360.profile_link(self.y360hash),
                           _('View Profile'))
            p[_('Yahoo! 360:')] = ['(', profilelink, ')', '\n'] + list(
                reversed(withnewlines))

            # Place Yahoo! 360 at the beginning.
            p.move(_('Yahoo! 360:'), 0)

        else:
            p = self.profile

        URL = ''.join([u'http://profiles.yahoo.com/', self.name])

        if p is not None:
            p[_(u'Directory URL:')] = ['\n', (URL, URL)]

        return self.reorder_profile(p) or None
Ejemplo n.º 22
0
    def pretty_profile(self):
        #p = odict(MSNSpaceElement.pretty_profile.fget(self).items())
        p = odict()
        for thing in self.contents:
            p.update(thing.pretty_profile.items())

        url = self.contents[0].url
        if not url and self.buddy.CID:
            url = ('http://spaces.live.com/Profile.aspx?cid=%s' % self.buddy.CID)
        elif not self.buddy.CID:
            return p

        assert url

        p['Profile URL:'] = ['\n', (url, url)]
        return p
Ejemplo n.º 23
0
	def __init__(self, element, parent, model):
		self.model = model
		self.element = element
		self.parent = parent
		self.base = element.getBase()
		self.name = element.getName()
		self.type = element.getType()
		self.properties = odict()
		if hasattr(element, 'appinfo') and element.appinfo == 'abstract':
			self.isAbstract = True
		else:
			self.isAbstract = False
		if hasattr(element, 'appinfo') \
		   and element.appinfo == 'abstract-proprietary':
			self.isAbstractProprietary = True
		else:
			self.isAbstractProprietary = False
Ejemplo n.º 24
0
 def __init__(self, element, parent, model):
     self.model = model
     self.element = element
     self.parent = parent
     self.base = element.getBase()
     self.name = element.getName()
     self.type = element.getType()
     self.properties = odict()
     self.isAbstract = False
     self.isAbstractProprietary = False
     self.isParentOrdered = False
     self.isChildOrdered = False
     self.isOrdered = False
     self.isUnique = False
     self.isImmutable = False
     self._isGlobal = False
     self.base in ('Annotation', 'BasicAnnotation') \
         or self.name == 'Annotation'
     self.plural = None
     self.manyToMany = False
     try:
         try:
             root = ElementTree.fromstring(element.appinfo)
         except:
             logging.error('Exception while parsing %r' % element.appinfo)
             raise
         if root.find('abstract') is not None:
             self.isAbstract = True
         if root.find('abstractproprietary') is not None:
             self.isAbstractProprietary = True
         if root.find('unique') is not None:
             self.isUnique = True
         if root.find('immutable') is not None:
             self.isImmutable = True
         if root.find('global') is not None:
             self._isGlobal = True
         if root.find('parentordered') is not None:
             self.isParentOrdered = True
         if root.find('childordered') is not None:
             self.isChildOrdered = True
         if root.find('ordered') is not None:
             self.isOrdered = True
         self.plural = root.findtext('plural')
     except AttributeError:
         pass
Ejemplo n.º 25
0
    def parseRevision(self):
        """
        Parse a revision, which may contain UserProperties and will
        not include TextContent::

          Revision =
            BeginRevision
            BlankLine?
            UserProperties?
            BlankLine*
            EndRevisionHeader
              (
              BeginNode
              BlankLine?
              UserProperties?
                (
                TextContent
                BlankLine
                )?
              BlankLine*
              )*
            EndRevisionNodes
        """
        dump_props = odict()
        rev = int(self.parseDumpProperty("Revision-number", dump_props))
        plen = int(self.parseDumpProperty("Prop-content-length", dump_props))
        clen = int(self.parseDumpProperty("Content-length", dump_props))
        assert clen - plen == 0, "A revision never has text content."

        yield BeginRevision(dump_props)

        if self.matchBlankLine():
            yield self.parseBlankLine()
        if self.matchUserProperties():
            yield self.parseUserProperties(plen)
        for evt in self.parseBlankLines():
            yield evt

        yield EndRevisionHeader()

        while self.matchNode():
            for evt in self.parseNode():
                yield evt

        yield EndRevisionNodes()
Ejemplo n.º 26
0
    def pretty_profile(self):
        #none = u'No Profile'
        if self.service != 'yahoo':
            return None

        if self.y360hash:
            p = odict(self.profile)

            now = time()
            filteredupdates = []

            for update_and_time in self.y360updates:
                try: update, tstamp = update_and_time
                except: continue
                if now - tstamp <= 60 * 60 * 24:
                    filteredupdates.append((update, tstamp))

            self.y360updates = filteredupdates

            ups = [u for u, t in self.y360updates]
            withnewlines = []
            if ups:
                for i, u in enumerate(ups):
                    withnewlines.append(u)
                    if i != len(ups) - 1: withnewlines.append('\n')
            else:
                withnewlines.append(_('No Updates'))

            from . import yahoo360
            profilelink = (yahoo360.profile_link(self.y360hash), _('View Profile'))
            p[_('Yahoo! 360:')] = ['(', profilelink, ')','\n'] + list(reversed(withnewlines))

            # Place Yahoo! 360 at the beginning.
            p.move(_('Yahoo! 360:'), 0)

        else:
            p=self.profile

        URL = ''.join([u'http://profiles.yahoo.com/', self.name])

        if p is not None:
            p[_(u'Directory URL:')] = ['\n',(URL,URL)]

        return self.reorder_profile(p) or None
Ejemplo n.º 27
0
    def __init__(self, title="Test - <Untitled>"):

        wx.Frame.__init__(self, None, -1, title)

        self.MenuBar = wx.MenuBar()

        self.menumap = {}

        menus = odict()
        menus['System'] = [('&About', self.OnAbout, 'About this test'), ('-'),
                           ('&Console', self.OnConsole, 'Digsby Shell'),
                           ('&Prefs', self.OnPrefs, 'Advanced Preferences'),
                           ('-'), ('E&xit', self.OnExit, 'Terminate Test App')]

        self.AddMenu(menus)

        Bind = self.Bind
        Bind(wx.EVT_MENU, self.OnMenu)
        Bind(wx.EVT_CLOSE, self.OnClose)
Ejemplo n.º 28
0
    def authorize_token(self, callback=None):

        params = util.odict(
            (('myspaceid.consumer_key', self.consumer.key),
             ('myspaceid.target_domain', 'http://www.digsby.com/myspace/'),
             ('myspaceid.permissions',
              '|'.join(self.required_permissions).lower())))

        def callback_url_function(cb_url):
            url = self.RequestFactory(
                self.urls['authorization'],
                callback_url=cb_url,
                oauth_url=True,
                sign=False,
                parameters=params,
            ).get_full_url()
            log.info("Callback URL function returning %r", url)
            return url

        self.event("open_oauth_page", callback_url_function, callback)
Ejemplo n.º 29
0
    def authorize_token(self, callback = None):

        params = util.odict((
                             ('myspaceid.consumer_key',   self.consumer.key),
                             ('myspaceid.target_domain',  'http://www.digsby.com/myspace/'),
                             ('myspaceid.permissions',    '|'.join(self.required_permissions).lower())
                             ))

        def callback_url_function(cb_url):
            url = self.RequestFactory(
                                      self.urls['authorization'],
                                      callback_url = cb_url,
                                      oauth_url = True,
                                      sign = False,
                                      parameters = params,
                                      ).get_full_url()
            log.info("Callback URL function returning %r", url)
            return url

        self.event("open_oauth_page", callback_url_function, callback)
Ejemplo n.º 30
0
    def load(self):
        emoticons_txt = self.path / 'emoticons.txt'
        if not emoticons_txt.isfile():
            raise Exception("%r not found", emoticons_txt)

        title = self.path.name
        emoticons = {}
        bitmaps = odict()

        with file(emoticons_txt) as f:
            # the first nonblank line is the title
            for line in f:
                line = line.strip()
                if line:
                    title = line
                    break

            for line in f:
                line = line.strip()
                if not line:
                    continue

                content = line.split()
                image_filename, smileys = content[0], content[1:]

                imgpath = self.path / image_filename
                if imgpath.isfile():
                    for smiley in smileys:
                        emoticons[smiley.encode('xml')] = S(path = imgpath)
                        if not imgpath in bitmaps:
                            bitmaps[imgpath] = [smiley]
                        else:
                            bitmaps[imgpath].append(smiley)

        self.name = title
        self.emoticons = emoticons
        self.bitmaps = bitmaps

        self.post_load()
Ejemplo n.º 31
0
    def load(self):
        emoticons_txt = self.path / 'emoticons.txt'
        if not emoticons_txt.isfile():
            raise Exception("%r not found", emoticons_txt)

        title = self.path.name
        emoticons = {}
        bitmaps = odict()

        with file(emoticons_txt) as f:
            # the first nonblank line is the title
            for line in f:
                line = line.strip()
                if line:
                    title = line
                    break

            for line in f:
                line = line.strip()
                if not line:
                    continue

                content = line.split()
                image_filename, smileys = content[0], content[1:]

                imgpath = self.path / image_filename
                if imgpath.isfile():
                    for smiley in smileys:
                        emoticons[smiley.encode('xml')] = S(path=imgpath)
                        if not imgpath in bitmaps:
                            bitmaps[imgpath] = [smiley]
                        else:
                            bitmaps[imgpath].append(smiley)

        self.name = title
        self.emoticons = emoticons
        self.bitmaps = bitmaps

        self.post_load()
Ejemplo n.º 32
0
    def __init__(self,title = "Test - <Untitled>"):

        wx.Frame.__init__(self,None,-1,title)

        self.MenuBar = wx.MenuBar()

        self.menumap = {}

        menus = odict()
        menus['System'] = [('&About'  , self.OnAbout  , 'About this test'     ),
                           ('-'                                               ),
                           ('&Console', self.OnConsole, 'Digsby Shell'        ),
                           ('&Prefs'  , self.OnPrefs  , 'Advanced Preferences'),
                           ('-'                                               ),
                           ('E&xit'   , self.OnExit   , 'Terminate Test App'  )]



        self.AddMenu(menus)

        Bind = self.Bind
        Bind(wx.EVT_MENU,self.OnMenu)
        Bind(wx.EVT_CLOSE, self.OnClose)
Ejemplo n.º 33
0
 def pretty_profile(self):
     return odict({self.title:'\n'})
Ejemplo n.º 34
0
    def pretty_profile(self):
        piclist=[x.pretty_profile for x in self]

        piclist.insert(0,'\n')
        return odict({'Photos:': piclist})
Ejemplo n.º 35
0
 def pretty_profile(self):
     return odict([post.pretty_profile for post in self])
Ejemplo n.º 36
0
	def __init__(self):
		self.elementNameObjectMap = dict()
		self.objects = odict()
		self.parents = dict()
Ejemplo n.º 37
0
 def __init__(self, opts):
     self.opts = opts
     self.elementNameObjectMap = dict()
     self.objects = odict()
     self.parents = dict()
Ejemplo n.º 38
0
 def pretty_profile(self, p=None):
     p = p or odict()
     #p[(self.title, self.url)] = self.description
     p[self.title+':'] = ['\n',(self.url, self.description)]
     return p
Ejemplo n.º 39
0
def thread_check():
    if threading.currentThread().getName() != 'MainThread':
        raise Exception('imhub methods must be called on the main GUI thread')


def info_key_tuple(info_key):
    i = info_key.find('_')
    if i == -1:
        assert False, repr(info_key)
    return info_key[:i], info_key[i+1:]

#
# hidden messages
#

hidden_windows = odict() # { contact: [message1, message2, ..] }

def hidden_count():
    'Returns the number of hidden conversation windows.'

    return len(hidden_windows)

def hidden_convo_contacts():
    'Returns a list of all contacts with hidden conversations.'

    return hidden_windows.keys()

def hide_message(messageobj, meta, sms, system_message):
    'Hides a message.'

    if messageobj is None:
Ejemplo n.º 40
0
 def request_info(self):
     if self.service == 'yahoo':
         yahooprofile.get(self.name, success = lambda p: setattr(self, 'profile', p))
     else:
         self.profile = odict()
Ejemplo n.º 41
0
    def pretty_profile(self):
        from util import odict

        if self.service=='aim':
            try:
                return self._pretty_profile
            except AttributeError:
                prof = [(aim_to_xhtml(self.profile) if self.profile else None)]

                from common import pref
                if pref('infobox.aim.show_profile_link', True):
                    # shows an aimpages.com profile link
                    linkage=odict()
                    linkage['space']=4
                    url=''.join(['http://www.aimpages.com/',self.name,'/profile.html'])
                    linkage[_('Profile URL:')]=['\n',(url,url)]

                    prof += [linkage]

                self._pretty_profile = prof
                return prof
        else:

            ok=False

            profile=odict()

            bget = make_dgetter(self)

            if bget('first') or bget('last'):
                profile[_('Full Name:')]=' '.join([self.first,self.last])
                ok=True

            personal = getattr(self, 'personal', {})
            if personal:
                pget = make_dgetter(personal)
                homeaddr = make_pretty_addr(personal)
            else:
                pget = lambda s:''
                homeaddr = ''

            keylabels = {'gender' : _('Gender'),
             'birthday' : _('Birthday')}
            for key in keylabels:
                if getattr(personal,key,False):
                    profile[_('{label}:').format(label = keylabels[key])] = pget(key)
                    ok=True


            p_web = pget('website')
            if p_web:
                profile[_('Website:')] = (p_web, p_web)
                ok=True


            prof = bget('profile')
            if prof:
                if ok: profile['sep1']=4

                try:
                    profstr = u'\n'+ prof
                except Exception:
                    pass
                else:
                    profile[_('Additional Information:')] = profstr

                ok=True

            if homeaddr:
                if ok: profile['sep2']=4
                profile[_('Home Address:')] = homeaddr
                ok=True

            work = getattr(self, 'work', {})
            if work:
                wget = make_dgetter(work)
                workaddr = make_pretty_addr(work)
            else:
                wget = lambda s:''
                workaddr =''

            if workaddr:
                if ok: profile['sep3']=4
                profile[_('Work Address:')] = workaddr
                ok=True

            if ok:
                profile['sep4']=4
                ok=False

            keylabels = {'company' : _('Company'), 'department' : _('Department'), 'position' : _('Position')}
            for key in keylabels:
                if getattr(work,key,False):
                    profile[_('{label}:').format(label = keylabels[key])] = wget(key)
                    ok=True

            w_web = wget('website')
            if w_web:
                profile[_('Work Website:')] = (w_web, w_web)
                ok=True

            if ok:
                ok=False
                profile['sep5']=4

            url=''.join([u'http://people.icq.com/people/about_me.php?uin=',self.name])
            profile[_('Profile URL:')]=['\n',(url,url)]


            return profile
Ejemplo n.º 42
0
# a unicode character showing two eighth notes joined by a bar
NOTES_SYMBOL = unichr(9835)
NOWPLAYING_STATUS_PREF = 'plugins.nowplaying.initial_status'

# this message is used when you have the "now playing" status selected, but
# aren't playing any music
NO_SONG_MESSAGE = _('Listening to music')

# these are names of modules containing "currentSong" methods
# each module is checked in order for a currently playing song
player_order = [
   ('winamp', 'Winamp'),
   ('itunes_win', 'iTunes')
]

song_checkers = odict()

def register(cls):
    if cls.app_name in song_checkers:
        song_checkers.pop(cls.app_name).release()

    song_checkers[cls.name_id] = cls()

class ThreadSafeLRU(LRU):
    def __getitem__(self, key):
        with self.lock:
            return LRU.__getitem__(self, key)

def change_hostname(url, newhost):
    url = list(urlparse(url))
    url[1] = newhost
Ejemplo n.º 43
0
 def request_info(self):
     if self.service == 'yahoo':
         yahooprofile.get(self.name,
                          success=lambda p: setattr(self, 'profile', p))
     else:
         self.profile = odict()
Ejemplo n.º 44
0
 def __init__(self):
     self.recipes = odict()
     self._logging_on = False
Ejemplo n.º 45
0
    def pretty_profile(self):
        songlist=[x.pretty_profile for x in self]

        songlist.insert(0,'\n')
        return odict({'Songs:': songlist})
Ejemplo n.º 46
0
 def pretty_profile(self):
     return odict(MSNSpaceElement.pretty_profile.fget(self).items())