home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.5)
-
- from util import callsback, Timer
- from logging import getLogger
- log = getLogger('common')
- info = log.info
-
- def setfakeprefs(userprefs):
- profile = profile
- import common
- profile.prefs.update(userprefs)
-
- castables = (int, float, long)
-
- def pref(pref, default = sentinel, type = sentinel):
-
- try:
- profile = profile
- import digsbyprofile
- except ImportError:
- if default is sentinel:
- raise KeyError('cannot get pref: no profile loaded')
- else:
- return default
- except:
- default is sentinel
-
- prefs = getattr(profile, 'prefs', { })
- if type is sentinel:
- return None if default is sentinel else prefs.get(pref, default)
- elif default is sentinel:
- pass
-
- val = prefs.get(pref, default)
- if type in castables:
-
- try:
- val = type(val)
- except ValueError:
- if default is sentinel:
- raise TypeError('pref val was incorrect type: %r' % val)
- else:
- return default
- except:
- default is sentinel
-
- return val
- elif not isinstance(val, type):
- if default is sentinel:
- raise TypeError('pref val was incorrect type: %r' % val)
- else:
- return default
-
- return val
-
-
- class prefprop(object):
- __slots__ = ('pref', 'default', 'type')
-
- def __init__(self, pref, default = sentinel, type = sentinel):
- self.pref = pref
- self.default = default
- self.type = type
-
-
- def __repr__(self):
- msg = repr(self.pref)
- if self.default is not sentinel:
- msg += ', default=%r' % self.default
-
- if self.type is not sentinel:
- msg += ', type=%r' % self.type
-
- return '<prefprop %s>' % msg
-
-
- def __get__(self, obj, objtype = None):
-
- try:
- return profile.prefs[self.pref]
- except KeyError:
- if self.default is sentinel:
- raise
- else:
- return self.default
- except:
- self.default is sentinel
-
-
-
-
- def netcall(callable, callback = None):
- call_later = call_later
- import AsyncoreThread
- call_later(callable, callback = callback)
-
- netcall = callsback(netcall)
-
- class _profile_thing(object):
-
- def __getattr__(self, attr):
- import digsbyprofile
- globals()['digsbyprofile'] = digsbyprofile
- object.__setattr__(self, '__getattr__', (lambda attr, dp = digsbyprofile: getattr(dp.profile, attr)))
- return getattr(digsbyprofile.profile, attr)
-
-
- def __setattr__(self, key, val):
- raise NotImplementedError()
-
-
- def __call__(self):
- profile = profile
- import digsbyprofile
- return profile
-
-
- def __nonzero__(self):
- profile = profile
- import digsbyprofile
- return bool(profile is not None)
-
-
- profile = _profile_thing()
- from common.notifications import fire
-
- def setpref(pref, val):
- profile = profile
- import digsbyprofile
- prefs = getattr(profile, 'prefs', { })
- prefs[pref] = val
-
-
- def silence_notifications(connection, duration = None):
- info('Silencing notifications from %r', connection)
- connection._notifyquiet = True
-
- def afterTimeout():
- connection._notifyquiet = False
- info('Unsilencing notifications from %r', connection)
-
- if duration is None:
- duration = pref('notifications.quiet_time', 5)
-
- Timer(duration, afterTimeout).start()
-
- import wx
- from inspect import getargspec
- from util import funcinfo
- from functools import wraps
-
- def bind(actionname):
-
- def wrap(func):
- args = getargspec(func)[0]
- if len(args) == 1 and args[0] == 'self':
-
- def cb(win, func = func):
- return func(win)
-
- else:
-
- def cb(win, func = func):
- return func()
-
- add_action_callback = add_action_callback
- import gui.input
- add_action_callback(actionname, cb)
- return func
-
- return wrap
-
- from hashacct import HashedAccount
- from Protocol import Protocol as protocol
- from Protocol import StateMixin
- from AsyncSocket import AsyncSocket as socket
- from Buddy import Buddy as buddy
- from Buddy import write_hashes, get_bname
- from Conversation import Conversation
- from actions import ActionMeta, action, Action, ActionError
- from timeoutsocket import TimeoutSocket, TimeoutSocketOne
- from hydrasocket import HydraSocket
- from filetransfer import FileTransfer, OutgoingFileTransfer, IncomingFileTransfer, IncomingHTTPFileTransfer
- from accountbase import AccountBase, FromNetMixin
- from statusmessage import StatusMessage, StatusMessageException, acct_reduce
- from UpdateMixin import UpdateMixin
- import commandline
-
- try:
- from contacts.Contact import ContactCapabilities as caps
- except ImportError:
- pass
-
-