signature
stringlengths
8
3.44k
body
stringlengths
0
1.41M
docstring
stringlengths
1
122k
id
stringlengths
5
17
def SmsTargetStatusToText(self, Status):
return self._ToText('<STR_LIT>', Status)<EOL>
Returns SMS target status as text. :Parameters: Status : `enums`.smsTargetStatus* SMS target status. :return: Text describing the SMS target status. :rtype: unicode
f12820:c0:m19
def TextToAttachmentStatus(self, Text):
conv = {'<STR_LIT>': enums.apiAttachUnknown,<EOL>'<STR_LIT>': enums.apiAttachSuccess,<EOL>'<STR_LIT>': enums.apiAttachPendingAuthorization,<EOL>'<STR_LIT>': enums.apiAttachRefused,<EOL>'<STR_LIT>': enums.apiAttachNotAvailable,<EOL>'<STR_LIT>': enums.apiAttachAvailable}<EOL>try:<EOL><INDENT>return self._TextTo('<STR_LIT>', conv[Text.upper()])<EOL><DEDENT>except KeyError:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>
Returns attachment status code. :Parameters: Text : unicode Text, one of 'UNKNOWN', 'SUCCESS', 'PENDING_AUTHORIZATION', 'REFUSED', 'NOT_AVAILABLE', 'AVAILABLE'. :return: Attachment status. :rtype: `enums`.apiAttach*
f12820:c0:m20
def TextToBuddyStatus(self, Text):
conv = {'<STR_LIT>': enums.budUnknown,<EOL>'<STR_LIT>': enums.budNeverBeenFriend,<EOL>'<STR_LIT>': enums.budDeletedFriend,<EOL>'<STR_LIT>': enums.budPendingAuthorization,<EOL>'<STR_LIT>': enums.budFriend}<EOL>try:<EOL><INDENT>return self._TextTo('<STR_LIT>', conv[Text.upper()])<EOL><DEDENT>except KeyError:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>
Returns buddy status code. :Parameters: Text : unicode Text, one of 'UNKNOWN', 'NEVER_BEEN_FRIEND', 'DELETED_FRIEND', 'PENDING_AUTHORIZATION', 'FRIEND'. :return: Buddy status. :rtype: `enums`.bud*
f12820:c0:m21
def TextToCallStatus(self, Text):
return self._TextTo('<STR_LIT>', Text)<EOL>
Returns call status code. :Parameters: Text : unicode Text, one of `enums`.cls*. :return: Call status. :rtype: `enums`.cls* :note: Currently, this method only checks if the given string is one of the allowed ones and returns it or raises a ``ValueError``.
f12820:c0:m22
def TextToCallType(self, Text):
return self._TextTo('<STR_LIT>', Text)<EOL>
Returns call type code. :Parameters: Text : unicode Text, one of `enums`.clt*. :return: Call type. :rtype: `enums`.clt* :note: Currently, this method only checks if the given string is one of the allowed ones and returns it or raises a ``ValueError``.
f12820:c0:m23
def TextToChatMessageStatus(self, Text):
return self._TextTo('<STR_LIT>', Text)<EOL>
Returns message status code. :Parameters: Text : unicode Text, one of `enums`.cms*. :return: Chat message status. :rtype: `enums`.cms* :note: Currently, this method only checks if the given string is one of the allowed ones and returns it or raises a ``ValueError``.
f12820:c0:m24
def TextToChatMessageType(self, Text):
return self._TextTo('<STR_LIT>', Text)<EOL>
Returns message type code. :Parameters: Text : unicode Text, one of `enums`.cme*. :return: Chat message type. :rtype: `enums`.cme* :note: Currently, this method only checks if the given string is one of the allowed ones and returns it or raises a ``ValueError``.
f12820:c0:m25
def TextToConnectionStatus(self, Text):
return self._TextTo('<STR_LIT>', Text)<EOL>
Retunes connection status code. :Parameters: Text : unicode Text, one of `enums`.con*. :return: Connection status. :rtype: `enums`.con* :note: Currently, this method only checks if the given string is one of the allowed ones and returns it or raises a ``ValueError``.
f12820:c0:m26
def TextToGroupType(self, Text):
return self._TextTo('<STR_LIT>', Text)<EOL>
Returns group type code. :Parameters: Text : unicode Text, one of `enums`.grp*. :return: Group type. :rtype: `enums`.grp* :note: Currently, this method only checks if the given string is one of the allowed ones and returns it or raises a ``ValueError``.
f12820:c0:m27
def TextToOnlineStatus(self, Text):
return self._TextTo('<STR_LIT>', Text)<EOL>
Returns online status code. :Parameters: Text : unicode Text, one of `enums`.ols*. :return: Online status. :rtype: `enums`.ols* :note: Currently, this method only checks if the given string is one of the allowed ones and returns it or raises a ``ValueError``.
f12820:c0:m28
def TextToUserSex(self, Text):
return self._TextTo('<STR_LIT>', Text)<EOL>
Returns user sex code. :Parameters: Text : unicode Text, one of `enums`.usex*. :return: User sex. :rtype: `enums`.usex* :note: Currently, this method only checks if the given string is one of the allowed ones and returns it or raises a ``ValueError``.
f12820:c0:m29
def TextToUserStatus(self, Text):
return self._TextTo('<STR_LIT>', Text)<EOL>
Returns user status code. :Parameters: Text : unicode Text, one of `enums`.cus*. :return: User status. :rtype: `enums`.cus* :note: Currently, this method only checks if the given string is one of the allowed ones and returns it or raises a ``ValueError``.
f12820:c0:m30
def TextToVoicemailStatus(self, Text):
return self._TextTo('<STR_LIT>', Text)<EOL>
Returns voicemail status code. :Parameters: Text : unicode Text, one of `enums`.vms*. :return: Voicemail status. :rtype: `enums`.vms* :note: Currently, this method only checks if the given string is one of the allowed ones and returns it or raises a ``ValueError``.
f12820:c0:m31
def UserSexToText(self, Sex):
return self._ToText('<STR_LIT>', Sex)<EOL>
Returns user sex as text. :Parameters: Sex : `enums`.usex* User sex. :return: Text describing the user sex. :rtype: unicode
f12820:c0:m32
def UserStatusToText(self, Status):
return self._ToText('<STR_LIT>', Status)<EOL>
Returns user status as text. :Parameters: Status : `enums`.cus* User status. :return: Text describing the user status. :rtype: unicode
f12820:c0:m33
def VoicemailFailureReasonToText(self, Reason):
return self._ToText('<STR_LIT>', Reason)<EOL>
Returns voicemail failure reason as text. :Parameters: Reason : `enums`.vmr* Voicemail failure reason. :return: Text describing the voicemail failure reason. :rtype: unicode
f12820:c0:m34
def VoicemailStatusToText(self, Status):
return self._ToText('<STR_LIT>', Status)<EOL>
Returns voicemail status as text. :Parameters: Status : `enums`.vms* Voicemail status. :return: Text describing the voicemail status. :rtype: unicode
f12820:c0:m35
def VoicemailTypeToText(self, Type):
return self._ToText('<STR_LIT>', Type)<EOL>
Returns voicemail type as text. :Parameters: Type : `enums`.vmt* Voicemail type. :return: Text describing the voicemail type. :rtype: unicode
f12820:c0:m36
def tounicode(s):
if isinstance(s, unicode):<EOL><INDENT>return s<EOL><DEDENT>return str(s).decode('<STR_LIT:utf-8>')<EOL>
Converts a string to a unicode string. Accepts two types or arguments. An UTF-8 encoded byte string or a unicode string (in the latter case, no conversion is performed). :Parameters: s : str or unicode String to convert to unicode. :return: A unicode string being the result of the conversion. :rtype: unicode
f12821:m0
def path2unicode(path):
return path.decode(sys.getfilesystemencoding())<EOL>
Decodes a file/directory path from the current file system encoding to unicode. :Parameters: path : str Encoded path. :return: Decoded path. :rtype: unicode
f12821:m1
def unicode2path(path):
return path.encode(sys.getfilesystemencoding())<EOL>
Encodes a file/directory path from unicode to the current file system encoding. :Parameters: path : unicode Decoded path. :return: Encoded path. :rtype: str
f12821:m2
def chop(s, n=<NUM_LIT:1>, d=None):
spl = s.split(d, n)<EOL>if len(spl) == n:<EOL><INDENT>spl.append(s[:<NUM_LIT:0>])<EOL><DEDENT>if len(spl) != n + <NUM_LIT:1>:<EOL><INDENT>raise ValueError('<STR_LIT>' % (n, s))<EOL><DEDENT>return spl<EOL>
Chops initial words from a string and returns a list of them and the rest of the string. The returned list is guaranteed to be n+1 long. If too little words are found in the string, a ValueError exception is raised. :Parameters: s : str or unicode String to chop from. n : int Number of words to chop. d : str or unicode Optional delimiter. Any white-char by default. :return: A list of n first words from the string followed by the rest of the string (``[w1, w2, ..., wn, rest_of_string]``). :rtype: list of: str or unicode
f12821:m3
def args2dict(s):
d = {}<EOL>while s:<EOL><INDENT>t, s = chop(s, <NUM_LIT:1>, '<STR_LIT:=>')<EOL>if s.startswith('<STR_LIT:">'):<EOL><INDENT>i = <NUM_LIT:0><EOL>while True:<EOL><INDENT>i = s.find('<STR_LIT:">', i+<NUM_LIT:1>)<EOL>try:<EOL><INDENT>if s[i+<NUM_LIT:1>] != '<STR_LIT:">':<EOL><INDENT>break<EOL><DEDENT>else:<EOL><INDENT>i += <NUM_LIT:1><EOL><DEDENT><DEDENT>except IndexError:<EOL><INDENT>break<EOL><DEDENT><DEDENT>if i > <NUM_LIT:0>:<EOL><INDENT>d[t] = s[<NUM_LIT:1>:i].replace('<STR_LIT>', '<STR_LIT:">')<EOL>if s[i+<NUM_LIT:1>:i+<NUM_LIT:3>] == '<STR_LIT:U+002CU+0020>':<EOL><INDENT>i += <NUM_LIT:2><EOL><DEDENT>s = s[i+<NUM_LIT:1>:]<EOL><DEDENT>else:<EOL><INDENT>d[t] = s<EOL>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>i = s.find('<STR_LIT:U+002CU+0020>')<EOL>if i >= <NUM_LIT:0>:<EOL><INDENT>d[t] = s[:i]<EOL>s = s[i+<NUM_LIT:2>:]<EOL><DEDENT>else:<EOL><INDENT>d[t] = s<EOL>break<EOL><DEDENT><DEDENT><DEDENT>return d<EOL>
Converts a string or comma-separated 'ARG="a value"' or 'ARG=value2' strings into a dictionary. :Parameters: s : str or unicode Input string. :return: ``{'ARG': 'value'}`` dictionary. :rtype: dict
f12821:m4
def quote(s, always=False):
if always or '<STR_LIT:U+0020>' in s:<EOL><INDENT>return '<STR_LIT>' % s.replace('<STR_LIT:">', '<STR_LIT>') <EOL><DEDENT>return s<EOL>
Adds double-quotes to string if it contains spaces. :Parameters: s : str or unicode String to add double-quotes to. always : bool If True, adds quotes even if the input string contains no spaces. :return: If the given string contains spaces or <always> is True, returns the string enclosed in double-quotes. Otherwise returns the string unchanged. :rtype: str or unicode
f12821:m5
def split(s, d=None):
if s:<EOL><INDENT>return s.split(d)<EOL><DEDENT>return []<EOL>
Splits a string. :Parameters: s : str or unicode String to split. d : str or unicode Optional delimiter. Any white-char by default. :return: A list of words or ``[]`` if the string was empty. :rtype: list of str or unicode :note: This function works like ``s.split(d)`` except that it always returns an empty list instead of ``['']`` for empty strings.
f12821:m6
def cndexp(condition, truevalue, falsevalue):
if condition:<EOL><INDENT>return truevalue<EOL><DEDENT>return falsevalue<EOL>
Simulates a conditional expression known from C or Python 2.5. :Parameters: condition : any Tells what should be returned. truevalue : any Value returned if condition evaluates to True. falsevalue : any Value returned if condition evaluates to False. :return: Either truevalue or falsevalue depending on condition. :rtype: same as type of truevalue or falsevalue
f12821:m7
def __init__(self, name, after, handlers, args, kwargs):
threading.Thread.__init__(self, name='<STR_LIT>' % name)<EOL>self.setDaemon(False)<EOL>self.after = after<EOL>self.handlers = handlers<EOL>self.args = args<EOL>self.kwargs = kwargs<EOL>
Initializes the object. :Parameters: name : str Event name. after : threading.Thread or None If not None, a thread that needs to end before this one starts. handlers : iterable Iterable of callable event handlers. args : tuple Positional arguments for the event handlers. kwargs : dict Keyword arguments for the event handlers. :note: When the thread is started (using the ``start`` method), it iterates over the handlers and calls them with the supplied arguments.
f12821:c0:m0
def __init__(self):
<EOL>self._EventThreads = weakref.WeakValueDictionary()<EOL>self._EventHandlerObject = None <EOL>self._DefaultEventHandlers = {} <EOL>self._EventHandlers = {} <EOL>self.__Logger = logging.getLogger('<STR_LIT>')<EOL>for event in self._EventNames:<EOL><INDENT>self._EventHandlers[event] = []<EOL><DEDENT>
Initializes the object.
f12821:c1:m0
def _CallEventHandler(self, Event, *Args, **KwArgs):
if Event not in self._EventHandlers:<EOL><INDENT>raise ValueError('<STR_LIT>' % (Event, self.__class__.__name__))<EOL><DEDENT>args = map(repr, Args) + ['<STR_LIT>' % (key, repr(value)) for key, value in KwArgs.items()]<EOL>self.__Logger.debug('<STR_LIT>', Event, '<STR_LIT:U+002CU+0020>'.join(args))<EOL>try:<EOL><INDENT>handlers = [self._DefaultEventHandlers[Event]]<EOL><DEDENT>except KeyError:<EOL><INDENT>handlers = []<EOL><DEDENT>try:<EOL><INDENT>handlers.append(getattr(self._EventHandlerObject, Event))<EOL><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><DEDENT>handlers.extend(self._EventHandlers[Event])<EOL>if handlers:<EOL><INDENT>after = self._EventThreads.get(Event, None)<EOL>thread = EventSchedulerThread(Event, after, handlers, Args, KwArgs)<EOL>self._EventThreads[Event] = thread<EOL>thread.start()<EOL><DEDENT>
Calls all event handlers defined for given Event, additional parameters will be passed unchanged to event handlers, all event handlers are fired on separate threads. :Parameters: Event : str Name of the event. Args Positional arguments for the event handlers. KwArgs Keyword arguments for the event handlers.
f12821:c1:m1
def RegisterEventHandler(self, Event, Target):
if not callable(Target):<EOL><INDENT>raise TypeError('<STR_LIT>' % repr(Target))<EOL><DEDENT>if Event not in self._EventHandlers:<EOL><INDENT>raise ValueError('<STR_LIT>' % (Event, self.__class__.__name__))<EOL><DEDENT>if Target in self._EventHandlers[Event]:<EOL><INDENT>return False<EOL><DEDENT>self._EventHandlers[Event].append(Target)<EOL>self.__Logger.info('<STR_LIT>', Event, repr(Target))<EOL>return True<EOL>
Registers any callable as an event handler. :Parameters: Event : str Name of the event. For event names, see the respective ``...Events`` class. Target : callable Callable to register as the event handler. :return: True is callable was successfully registered, False if it was already registered. :rtype: bool :see: `UnregisterEventHandler`
f12821:c1:m2
def UnregisterEventHandler(self, Event, Target):
if not callable(Target):<EOL><INDENT>raise TypeError('<STR_LIT>' % repr(Target))<EOL><DEDENT>if Event not in self._EventHandlers:<EOL><INDENT>raise ValueError('<STR_LIT>' % (Event, self.__class__.__name__))<EOL><DEDENT>if Target in self._EventHandlers[Event]:<EOL><INDENT>self._EventHandlers[Event].remove(Target)<EOL>self.__Logger.info('<STR_LIT>', Event, repr(Target))<EOL>return True<EOL><DEDENT>return False<EOL>
Unregisters an event handler previously registered with `RegisterEventHandler`. :Parameters: Event : str Name of the event. For event names, see the respective ``...Events`` class. Target : callable Callable to unregister. :return: True if callable was successfully unregistered, False if it wasn't registered first. :rtype: bool :see: `RegisterEventHandler`
f12821:c1:m3
def _SetEventHandlerObject(self, Object):
self._EventHandlerObject = Object<EOL>self.__Logger.info('<STR_LIT>', repr(Object))<EOL>
Registers an object as events handler, object should contain methods with names corresponding to event names, only one object may be registered at a time. :Parameters: Object Object to register. May be None in which case the currently registered object will be unregistered.
f12821:c1:m6
@classmethod<EOL><INDENT>def _AddEvents(cls, Class):<DEDENT>
def make_event(event):<EOL><INDENT>return property(lambda self: self._GetDefaultEventHandler(event),<EOL>lambda self, Value: self._SetDefaultEventHandler(event, Value))<EOL><DEDENT>for event in dir(Class):<EOL><INDENT>if not event.startswith('<STR_LIT:_>'):<EOL><INDENT>setattr(cls, '<STR_LIT>' % event, make_event(event))<EOL>cls._EventNames.append(event)<EOL><DEDENT><DEDENT>
Adds events based on the attributes of the given ``...Events`` class. :Parameters: Class : class An `...Events` class whose methods define events that may occur in the instances of the current class.
f12821:c1:m7
def _Init(self):
Initializes the cached object. Receives all the arguments passed to the constructor The default implementation stores the ``Owner`` in ``self._Owner`` and ``Handle`` in ``self._Handle``. This method should be used instead of ``__init__`` to prevent double initialization.
f12821:c2:m1
def _MakeOwner(self):
self._CreateOwner(self)<EOL>
Prepares the object for use as an owner for other cached objects.
f12821:c2:m4
@staticmethod<EOL><INDENT>def _CreateOwner(Object):<DEDENT>
Object._ObjectCache = weakref.WeakValueDictionary()<EOL>
Prepares any object for use as an owner for cached objects. :Parameters: Object Object that should be turned into a cached objects owner.
f12821:c2:m5
def Delete(self):
self._Owner._DoCommand('<STR_LIT>' % self.Id)<EOL>
Deletes this SMS message.
f12822:c0:m4
def MarkAsSeen(self):
self._Owner._DoCommand('<STR_LIT>' % self.Id)<EOL>
Marks this SMS message as seen.
f12822:c0:m5
def Send(self):
self._Alter('<STR_LIT>')<EOL>
Sends this SMS message.
f12822:c0:m6
def _Alter(self, AlterName, Args=None):
return self._Owner._Alter('<STR_LIT>', self.Name, AlterName, Args,<EOL>'<STR_LIT>' % (AlterName))<EOL>
--- Prajna bug fix --- Original code: return self._Owner._Alter('CHAT', self.Name, AlterName, Args, 'ALTER CHAT %s %s' % (self.Name, AlterName)) Whereas most of the ALTER commands echo the command in the reply, the ALTER CHAT commands strip the <chat_id> from the reply, so we need to do the same for the expected reply
f12824:c0:m1
def AcceptAdd(self):
self._Alter('<STR_LIT>')<EOL>
Accepts a shared group add request.
f12824:c0:m3
def AddMembers(self, *Members):
self._Alter('<STR_LIT>', '<STR_LIT:U+002CU+0020>'.join([x.Handle for x in Members]))<EOL>
Adds new members to the chat. :Parameters: Members : `User` One or more users to add.
f12824:c0:m4
def Bookmark(self):
self._Alter('<STR_LIT>')<EOL>
Bookmarks the chat in Skype client.
f12824:c0:m5
def ClearRecentMessages(self):
self._Alter('<STR_LIT>')<EOL>
Clears recent chat messages.
f12824:c0:m6
def Disband(self):
self._Alter('<STR_LIT>')<EOL>
Ends the chat.
f12824:c0:m7
def EnterPassword(self, Password):
self._Alter('<STR_LIT>', tounicode(Password))<EOL>
Enters chat password. :Parameters: Password : unicode Password
f12824:c0:m8
def Join(self):
self._Alter('<STR_LIT>')<EOL>
Joins the chat.
f12824:c0:m9
def Kick(self, *Handles):
self._Alter('<STR_LIT>', '<STR_LIT:U+002CU+0020>'.join(Handles))<EOL>
Kicks member(s) from chat. :Parameters: Handles : str Skype username(s).
f12824:c0:m10
def KickBan(self, *Handles):
self._Alter('<STR_LIT>', '<STR_LIT:U+002CU+0020>'.join(Handles))<EOL>
Kicks and bans member(s) from chat. :Parameters: Handles : str Skype username(s).
f12824:c0:m11
def Leave(self):
self._Alter('<STR_LIT>')<EOL>
Leaves the chat.
f12824:c0:m12
def OpenWindow(self):
self._Owner.Client.OpenDialog('<STR_LIT>', self.Name)<EOL>
Opens the chat window.
f12824:c0:m13
def SendMessage(self, MessageText):
return ChatMessage(self._Owner, chop(self._Owner._DoCommand('<STR_LIT>' % (self.Name,<EOL>tounicode(MessageText))), <NUM_LIT:2>)[<NUM_LIT:1>])<EOL>
Sends a chat message. :Parameters: MessageText : unicode Message text :return: Message object :rtype: `ChatMessage`
f12824:c0:m14
def SetPassword(self, Password, Hint='<STR_LIT>'):
if '<STR_LIT:U+0020>' in Password:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>self._Alter('<STR_LIT>', '<STR_LIT>' % (tounicode(Password), tounicode(Hint)))<EOL>
Sets the chat password. :Parameters: Password : unicode Password Hint : unicode Password hint
f12824:c0:m15
def Unbookmark(self):
self._Alter('<STR_LIT>')<EOL>
Unbookmarks the chat.
f12824:c0:m16
def MarkAsSeen(self):
self._Owner._DoCommand('<STR_LIT>' % self.Id, '<STR_LIT>' % self.Id)<EOL>
Marks a missed chat message as seen.
f12824:c2:m2
def CanSetRoleTo(self, Role):
t = self._Owner._Alter('<STR_LIT>', self.Id, '<STR_LIT>', Role,<EOL>'<STR_LIT>')<EOL>return (chop(t, <NUM_LIT:1>)[-<NUM_LIT:1>] == '<STR_LIT>')<EOL>
Checks if the new role can be applied to the member. :Parameters: Role : `enums`.chatMemberRole* New chat member role. :return: True if the new role can be applied, False otherwise. :rtype: bool
f12824:c4:m3
def CaptureMicDevice(self, DeviceType=None, Set=NoneType):
return self._Device('<STR_LIT>', DeviceType, Set)<EOL>
Queries or sets the mic capture device. :Parameters: DeviceType : `enums`.callIoDeviceType* or None Mic capture device type. Set Value the device should be set to or None if it should be deactivated. Querying all active devices: Devices = CaptureMicDevice() Returns a mapping of device types to their values. Only active devices are returned. Querying a specific device: Value = CaptureMicDevice(DeviceType) Returns a device value for the given DeviceType. Setting a device value: CaptureMicDevice(DeviceType, Value) If Value is None, the device will be deactivated. :note: This command functions for active calls only.
f12825:c0:m1
def InputDevice(self, DeviceType=None, Set=NoneType):
return self._Device('<STR_LIT>', DeviceType, Set)<EOL>
Queries or sets the sound input device. :Parameters: DeviceType : `enums`.callIoDeviceType* or None Sound input device type. Set Value the device should be set to or None if it should be deactivated. Querying all active devices: Devices = InputDevice() Returns a mapping of device types to their values. Only active devices are returned. Querying a specific device: Value = InputDevice(DeviceType) Returns a device value for the given DeviceType. Setting a device value: InputDevice(DeviceType, Value) If Value is None, the device will be deactivated. :note: This command functions for active calls only.
f12825:c0:m2
def OutputDevice(self, DeviceType=None, Set=NoneType):
return self._Device('<STR_LIT>', DeviceType, Set)<EOL>
Queries or sets the sound output device. :Parameters: DeviceType : `enums`.callIoDeviceType* or None Sound output device type. Set Value the device should be set to or None if it should be deactivated. Querying all active devices: Devices = OutputDevice() Returns a mapping of device types to their values. Only active devices are returned. Querying a specific device: Value = OutputDevice(DeviceType) Returns a device value for the given DeviceType. Setting a device value: OutputDevice(DeviceType, Value) If Value is None, the device will be deactivated. :note: This command functions for active calls only.
f12825:c0:m3
def Answer(self):
<EOL>self._Alter('<STR_LIT>')<EOL>
Answers the call.
f12825:c1:m4
def CanTransfer(self, Target):
return self._Property('<STR_LIT>' % Target) == '<STR_LIT>'<EOL>
Queries if a call can be transferred to a contact or phone number. :Parameters: Target : str Skypename or phone number the call is to be transferred to. :return: True if call can be transferred, False otherwise. :rtype: bool
f12825:c1:m5
def Finish(self):
<EOL>self._Alter('<STR_LIT>', '<STR_LIT>')<EOL>
Ends the call.
f12825:c1:m6
def Forward(self):
self._Alter('<STR_LIT>', '<STR_LIT>')<EOL>
Forwards a call.
f12825:c1:m7
def Hold(self):
<EOL>self._Alter('<STR_LIT>')<EOL>
Puts the call on hold.
f12825:c1:m8
def Join(self, Id):
<EOL>reply = self._Owner._DoCommand('<STR_LIT>' % (self.Id, Id),<EOL>'<STR_LIT>' % self.Id)<EOL>return Conference(self._Owner, reply.split()[-<NUM_LIT:1>])<EOL>
Joins with another call to form a conference. :Parameters: Id : int Call Id of the other call to join to the conference. :return: Conference object. :rtype: `Conference`
f12825:c1:m9
def MarkAsSeen(self):
self.Seen = True<EOL>
Marks the call as seen.
f12825:c1:m10
def RedirectToVoicemail(self):
self._Alter('<STR_LIT>', '<STR_LIT>')<EOL>
Redirects a call to voicemail.
f12825:c1:m11
def Resume(self):
<EOL>self._Alter('<STR_LIT>')<EOL>
Resumes the held call.
f12825:c1:m12
def StartVideoReceive(self):
self._Alter('<STR_LIT>')<EOL>
Starts video receive.
f12825:c1:m13
def StartVideoSend(self):
self._Alter('<STR_LIT>')<EOL>
Starts video send.
f12825:c1:m14
def StopVideoReceive(self):
self._Alter('<STR_LIT>')<EOL>
Stops video receive.
f12825:c1:m15
def StopVideoSend(self):
self._Alter('<STR_LIT>')<EOL>
Stops video send.
f12825:c1:m16
def Transfer(self, *Targets):
self._Alter('<STR_LIT>', '<STR_LIT:U+002CU+0020>'.join(Targets))<EOL>
Transfers a call to one or more contacts or phone numbers. :Parameters: Targets : str one or more phone numbers or Skypenames the call is being transferred to. :note: You can transfer an incoming call to a group by specifying more than one target, first one of the group to answer will get the call. :see: `CanTransfer`
f12825:c1:m17
def Finish(self):
for c in self._GetCalls():<EOL><INDENT>c.Finish()<EOL><DEDENT>
Finishes a conference so all active calls have the status `enums.clsFinished`.
f12825:c5:m1
def Hold(self):
for c in self._GetCalls():<EOL><INDENT>c.Hold()<EOL><DEDENT>
Places all calls in a conference on hold so all active calls have the status `enums.clsLocalHold`.
f12825:c5:m2
def Resume(self):
for c in self._GetCalls():<EOL><INDENT>c.Resume()<EOL><DEDENT>
Resumes a conference that was placed on hold so all active calls have the status `enums.clsInProgress`.
f12825:c5:m3
def setUpObject(self):
self.obj = None<EOL>
Override to set the "obj" attribute to the tested Skype4Py object.
f12827:c1:m2
def tearDownObject(self):
del self.obj<EOL>
Override to delete the tested object ("obj" attribute).
f12827:c1:m3
def assertInstance(self, value, types):
self.failUnless(isinstance(value, types),<EOL>'<STR_LIT>' % (repr(value), types))<EOL>
Tests if value is an instance of types which may be a type or tuple of types (in which case value type may be one them).
f12827:c1:m4
def __delitem__(self, key):
logger.debug('<STR_LIT>', key)<EOL>return self._redis.delete(key)<EOL>
Delete one or more keys specified by ``key`` :param key: key to delete :type key: str :return: 1 if deleted, 0 if not :rtype: int
f12839:c0:m1
def __getitem__(self, item):
logger.debug('<STR_LIT>', item)<EOL>if not self.__contains__(item):<EOL><INDENT>raise KeyError(item)<EOL><DEDENT>key_type = self._redis.type(item)<EOL>if isinstance(key_type, bytes):<EOL><INDENT>key_type = key_type.decode()<EOL><DEDENT>logger.debug('<STR_LIT>', item, key_type)<EOL>if key_type == '<STR_LIT>':<EOL><INDENT>return self._redis.hgetall(item)<EOL><DEDENT>elif key_type == '<STR_LIT:list>':<EOL><INDENT>return self._redis.lrange(item, <NUM_LIT:0>, -<NUM_LIT:1>)<EOL><DEDENT>elif key_type == '<STR_LIT>':<EOL><INDENT>return self._redis.smembers(item)<EOL><DEDENT>elif str(key_type) == '<STR_LIT>':<EOL><INDENT>return self._redis.zrange(item, <NUM_LIT:0>, -<NUM_LIT:1>)<EOL><DEDENT>return self._redis.get(item)<EOL>
Return the value at key ``item`` or None if item doesn't exists :param item: item name :type item: str :return: value of item with given name :rtype: Any
f12839:c0:m2
def __setitem__(self, key, value):
logger.debug('<STR_LIT>', key)<EOL>if isinstance(value, (tuple, list)):<EOL><INDENT>self._redis.delete(key)<EOL>self._redis.rpush(key, *value)<EOL><DEDENT>elif isinstance(value, dict):<EOL><INDENT>self._redis.hmset(key, value)<EOL><DEDENT>elif isinstance(value, set):<EOL><INDENT>self._redis.sadd(key, *value)<EOL><DEDENT>else:<EOL><INDENT>self._redis.set(key, value)<EOL><DEDENT>
Set the value at key ``key`` to ``value`` :param key: item name :type key: str :param value: item value :type value: Any :return: None :rtype: None
f12839:c0:m3
def __iter__(self):
return self.iterkeys()<EOL>
Return iterator over db's keys :return:
f12839:c0:m4
def __contains__(self, item):
logger.debug('<STR_LIT>', item)<EOL>return self._redis.exists(item)<EOL>
Return a boolean indicating whether key ``item`` exists >>> dc = Dictator() >>> 'theKey' in dc False :param item: item name :type item: str :return: True if exists or False in other case :rtype: bool
f12839:c0:m5
def __len__(self):
logger.debug('<STR_LIT>')<EOL>return self._redis.dbsize()<EOL>
Return number of items in db >>> dc = Dictator() >>> len(dc) 0 >>> dc['a'] = 'a' >>> len(dc) 1 >>> del dc['a'] >>> len(dc) 0 :return: number of items in db :rtype: int
f12839:c0:m6
def copy(self):
logger.debug('<STR_LIT>')<EOL>return {key: self.get(key) for key in self.keys()}<EOL>
Convert ``Dictator`` to standard ``dict`` object >>> dc = Dictator() >>> dc['l0'] = [1, 2] >>> dc['1'] = 'abc' >>> d = dc.copy() >>> type(d) dict >>> d {'l0': ['1', '2'], '1': 'abc'} >>> dc.clear() :return: Python's dict object :rtype: dict
f12839:c0:m7
def __deepcopy__(self, memo):
return self.copy()<EOL>
Convert ``Dictator`` to standard ``dict`` object by simply calling ``copy()`` method.
f12839:c0:m8
def set(self, key, value):
self.__setitem__(key, value)<EOL>
Set the value at key ``key`` to ``value`` >>> dc = Dictator() >>> dc['s0'] = 'string value' >>> dc['s0'] 'string value' >>> dc.set('l0', ['abc', 123]) >>> dc['l0'] ['abc', '123'] >>> dc.set([1, 2, 3], ['a', 'b']) >>> dc['[1, 2, 3]'] ['a', 'b'] >>> dc.clear() :param key: any value (will be converted to string in Redis) :type key: Any :param value: Any :return: None :rtype None
f12839:c0:m9
def get(self, key, default=None):
try:<EOL><INDENT>value = self.__getitem__(key)<EOL><DEDENT>except KeyError:<EOL><INDENT>value = None<EOL><DEDENT>if isinstance(value, bytes):<EOL><INDENT>value = value.decode()<EOL><DEDENT>return value or default<EOL>
Return the value at key ``key``, or default value ``default`` which is None by default. >>> dc = Dictator() >>> dc['l0'] = [1, 2, 3, 4] >>> dc.get('l0') ['1', '2', '3', '4'] >>> dc['l0'] ['1', '2', '3', '4'] >>> dc.clear() :param key: key of value to return :type key: str :param default: value of any type to return of key doesn't exist. :type default: Any :return: value of given key :rtype: Any
f12839:c0:m10
def clear(self):
logger.debug('<STR_LIT>')<EOL>self._redis.flushdb()<EOL>
Remove all items in current db. >>> dc = Dictator() >>> dc['Stars'] = ['Sun', 'Vega'] >>> len(dc) 1 >>> dc.clear() >>> len(dc) 0
f12839:c0:m11
def pop(self, key, default=None):
logger.debug('<STR_LIT>', key)<EOL>value = self.get(key)<EOL>self._redis.delete(key)<EOL>return value or default<EOL>
Remove and return the last item of the list ``key``. If key doesn't exists it return ``default``. >>> dc = Dictator() >>> dc['l0'] = [1, 2, 3, 4] >>> dc.pop('l0') ['1', '2', '3', '4'] >>> dc.pop('l1', 'empty') 'empty' :param key: key name to pop :type key: str :param default: default value if key doesn't exist :type default: Any :return: value associated with given key or None or ``default`` :rtype: Any
f12839:c0:m12
def keys(self, pattern=None):
logger.debug('<STR_LIT>', pattern)<EOL>if pattern is None:<EOL><INDENT>pattern = '<STR_LIT:*>'<EOL><DEDENT>return self._redis.keys(pattern=pattern)<EOL>
Returns a list of keys matching ``pattern``. By default return all keys. >>> dc = Dictator() >>> dc['l0'] = [1, 2, 3, 4] >>> dc['s0'] = 'string value' >>> dc.keys() ['l0', 's0'] >>> dc.keys('h*') [] >>> dc.clear() :param pattern: key pattern :type pattern: str :return: list of keys in db :rtype: list of str
f12839:c0:m13
def items(self):
logger.debug('<STR_LIT>')<EOL>return [(key, self.get(key)) for key in self.keys()]<EOL>
Return list of tuples of keys and values in db >>> dc = Dictator() >>> dc['l0'] = [1, 2, 3, 4] >>> dc.items() [('l0', ['1', '2', '3', '4'])] >>> dc.clear() :return: list of (key, value) pairs :rtype: list of tuple
f12839:c0:m14
def values(self):
logger.debug('<STR_LIT>')<EOL>return [self.get(key) for key in self.keys()]<EOL>
Return list of values in db >>> dc = Dictator() >>> dc['l0'] = [1, 2, 3, 4] >>> dc.items() [('l0', ['1', '2', '3', '4'])] >>> dc.clear() :return: list of tuple :rtype: list
f12839:c0:m15
def iterkeys(self, match=None, count=<NUM_LIT:1>):
logger.debug('<STR_LIT>', match)<EOL>if match is None:<EOL><INDENT>match = '<STR_LIT:*>'<EOL><DEDENT>for key in self._redis.scan_iter(match=match, count=count):<EOL><INDENT>yield key<EOL><DEDENT>
Return an iterator over the db's keys. ``match`` allows for filtering the keys by pattern. ``count`` allows for hint the minimum number of returns. >>> dc = Dictator() >>> dc['1'] = 'abc' >>> dc['2'] = 'def' >>> dc['3'] = 'ghi' >>> itr = dc.iterkeys() >>> type(itr) <type 'generator'> >>> list(reversed([item for item in itr])) ['1', '2', '3'] >>> dc.clear() :param match: pattern to filter keys :type match: str :param count: minimum number of returns :type count: int :return: iterator over key. :rtype: generator
f12839:c0:m16
def iteritems(self, match=None, count=<NUM_LIT:1>):
logger.debug('<STR_LIT>', match)<EOL>if match is None:<EOL><INDENT>match = '<STR_LIT:*>'<EOL><DEDENT>for key in self._redis.scan_iter(match=match, count=count):<EOL><INDENT>yield key, self.get(key)<EOL><DEDENT>
Return an iterator over the db's (key, value) pairs. ``match`` allows for filtering the keys by pattern. ``count`` allows for hint the minimum number of returns. >>> dc = Dictator() >>> dc['1'] = 'abc' >>> dc['2'] = 'def' >>> dc['3'] = 'ghi' >>> itr = dc.iteritems() >>> type(itr) <type 'generator'> >>> list(reversed([item for item in itr])) [('1', 'abc'), ('2', 'def'), ('3', 'ghi')] >>> dc.clear() :param match: pattern to filter keys :type match: str :param count: minimum number of returns :type count: int :return: iterator over key, value pairs. :rtype: generator
f12839:c0:m17
def update(self, other=None, **kwargs):
logger.debug('<STR_LIT>', other)<EOL>if other:<EOL><INDENT>if hasattr(other, '<STR_LIT>'):<EOL><INDENT>for key in other.keys():<EOL><INDENT>self.set(key, other[key])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>for (key, value) in other:<EOL><INDENT>self.set(key, value)<EOL><DEDENT><DEDENT><DEDENT>if kwargs:<EOL><INDENT>for key, value in six.iteritems(kwargs):<EOL><INDENT>self.set(key, value)<EOL><DEDENT><DEDENT>
D.update([other, ]**kwargs) -> None. Update D From dict/iterable ``other`` and ``kwargs``. If ``other`` present and has a .keys() method, does: for k in other: D[k] = other[k] If ``other`` present and lacks .keys() method, does: for (k, v) in other: D[k] = v In either case, this is followed by: for k in kwargs: D[k] = kwargs[k] >>> dc = Dictator() >>> dc['1'] = 'abc' >>> dc['2'] = 'def' >>> dc.values() ['def', 'abc'] >>> dc.update({'3': 'ghi'}, name='Keys') >>> dc.values() ['Keys', 'ghi', 'def', 'abc'] >>> dc.clear() :param other: dict/iterable with .keys() function. :param kwargs: key/value pairs
f12839:c0:m18
def __getattr__(self, item):
if hasattr(self._redis, item):<EOL><INDENT>return getattr(self._redis, item)<EOL><DEDENT>else:<EOL><INDENT>raise AttributeError(<EOL>'<STR_LIT>'.format(item)<EOL>)<EOL><DEDENT>
If some attribute is not defined for ``Dictator``, try to find this method in ``redis-py`` instance >>> dc = Dictator() >>> dc['1'] = 'abc' >>> dc['2'] = 'def' >>> dc.keys() ['1', '2'] >>> lock = dc.lock('Lock') >>> lock.acquire() >>> dc.keys() ['Lock', '1', '2'] >>> lock.release() ['1', '2'] >>> dc.unknown_attr() Traceback (most recent call last): ... AttributeError: 'Dictator' object has no attribute 'count' >>> dc.clear() :param item: item to try to get from ``redis-py`` instance :return: method or variable's value :rtype: Any
f12839:c0:m19
def __init__(self, signed_request=None, application_secret_key=None, application_id=None, api_version=None):
self.signed_request = signed_request<EOL>self.application_secret_key = application_secret_key<EOL>self.application_id = application_id<EOL>self.api_version = api_version<EOL>self.raw = self.parse(signed_request, application_secret_key)<EOL>self.data = self.raw.get('<STR_LIT>', None)<EOL>self.page = self.Page(<EOL>id=self.raw['<STR_LIT>'].get('<STR_LIT:id>'),<EOL>is_liked=self.raw['<STR_LIT>'].get('<STR_LIT>'),<EOL>is_admin=self.raw['<STR_LIT>'].get('<STR_LIT>')<EOL>) if '<STR_LIT>' in self.raw else None<EOL>if '<STR_LIT:user>' not in self.raw:<EOL><INDENT>self.fetch_user_data_and_token()<EOL><DEDENT>self.user = self.User(<EOL>id=self.raw.get('<STR_LIT>'),<EOL>locale=self.raw['<STR_LIT:user>'].get('<STR_LIT>', None),<EOL>country=self.raw['<STR_LIT:user>'].get('<STR_LIT>', None),<EOL>age=range(<EOL>self.raw['<STR_LIT:user>']['<STR_LIT>']['<STR_LIT>'],<EOL>self.raw['<STR_LIT:user>']['<STR_LIT>']['<STR_LIT>'] + <NUM_LIT:1> if '<STR_LIT>' in self.raw['<STR_LIT:user>']['<STR_LIT>'] else <NUM_LIT:100><EOL>) if '<STR_LIT>' in self.raw['<STR_LIT:user>'] else None,<EOL>oauth_token=self.User.OAuthToken(<EOL>token=self.raw['<STR_LIT>'],<EOL>issued_at=datetime.fromtimestamp(self.raw['<STR_LIT>']),<EOL>expires_at=datetime.fromtimestamp(self.raw['<STR_LIT>']) if self.raw['<STR_LIT>'] > <NUM_LIT:0> else None<EOL>) if '<STR_LIT>' in self.raw else None,<EOL>)<EOL>
Initialize a signed request. :param signed_request: A string describing a signed request. :param application_secret_key: A string describing a Facebook application's secret key.
f12845:c0:m0
def parse(cls, signed_request, application_secret_key):
def decode(encoded):<EOL><INDENT>padding = '<STR_LIT:=>' * (len(encoded) % <NUM_LIT:4>)<EOL>return base64.urlsafe_b64decode(encoded + padding)<EOL><DEDENT>try:<EOL><INDENT>encoded_signature, encoded_payload = (str(string) for string in signed_request.split('<STR_LIT:.>', <NUM_LIT:2>))<EOL>signature = decode(encoded_signature)<EOL>signed_request_data = json.loads(decode(encoded_payload).decode('<STR_LIT:utf-8>'))<EOL><DEDENT>except (TypeError, ValueError):<EOL><INDENT>raise SignedRequestError("<STR_LIT>")<EOL><DEDENT>if signed_request_data.get('<STR_LIT>', '<STR_LIT>').upper() != '<STR_LIT>':<EOL><INDENT>raise SignedRequestError("<STR_LIT>")<EOL><DEDENT>expected_signature = hmac.new(application_secret_key.encode('<STR_LIT:utf-8>'), msg=encoded_payload.encode('<STR_LIT:utf-8>'),<EOL>digestmod=hashlib.sha256).digest()<EOL>if signature != expected_signature:<EOL><INDENT>raise SignedRequestError("<STR_LIT>")<EOL><DEDENT>return signed_request_data<EOL>
Parse a signed request, returning a dictionary describing its payload.
f12845:c0:m2