Package Skype4Py :: Module utils
[frames] | no frames]

Module utils

source code

Utility functions and classes used internally by Skype4Py.

Classes
  EventHandlingBase
This class is used as a base by all classes implementing event handlers.
  Cached
Base class for all cached objects.
Functions
list of str or unicode
chop(s, n=1, d=None)
Chops initial words from a string and returns a list of them and the rest of the string.
source code
dict
args2dict(s)
Converts a string in 'ARG="value", ARG2="value2"' format into a dictionary.
source code
str or unicode
quote(s, always=False)
Adds double-quotes to string if needed.
source code
list of str or unicode
esplit(s, d=None)
Splits a string into words.
source code
same as type of truevalue or falsevalue
cndexp(condition, truevalue, falsevalue)
Simulates a conditional expression known from C or Python 2.5+.
source code
weakref
WeakCallableRef(c, callback=None)
Creates and returns a new weak reference to a callable object.
source code
Variables
  __package__ = 'Skype4Py'
Function Details

chop(s, n=1, d=None)

source code 

Chops initial words from a string and returns a list of them and the rest of the string.

Parameters:
  • s (str or unicode) - String to chop from.
  • n (int) - Number of words to chop.
  • d (str or unicode) - Optional delimeter. Any white-char by default.
Returns: list of str or unicode
A list of n first words from the string followed by the rest of the string ([w1, w2, ..., wn, rest_of_string]).

args2dict(s)

source code 

Converts a string in 'ARG="value", ARG2="value2"' format into a dictionary.

Parameters:
  • s (str or unicode) - Input string with comma-separated 'ARG="value"' strings.
Returns: dict
{'ARG': 'value'} dictionary.

quote(s, always=False)

source code 

Adds double-quotes to string if needed.

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.
Returns: str or unicode
If the given string contains spaces or always=True, returns the string enclosed in double-quotes (if it contained quotes too, they are preceded with a backslash). Otherwise returns the string unchnaged.

esplit(s, d=None)

source code 

Splits a string into words.

Parameters:
  • s (str or unicode) - String to split.
  • d (str or unicode) - Optional delimeter. Any white-char by default.
Returns: list of str or unicode
A list of words or [] if the string was empty.

Note: This function works like s.split(d) except that it always returns an empty list instead of [''] for empty strings.

cndexp(condition, truevalue, falsevalue)

source code 

Simulates a conditional expression known from C or Python 2.5+.

Parameters:
  • condition (bool, see note) - Boolean value telling what should be returned.
  • truevalue (any) - Value returned if condition was True.
  • falsevalue (any) - Value returned if condition was False.
Returns: same as type of truevalue or falsevalue
Either truevalue or falsevalue depending on condition.

Note: The type of condition parameter can be anything as long as bool(condition) returns a bool value.

WeakCallableRef(c, callback=None)

source code 

Creates and returns a new weak reference to a callable object.

In contrast to weakref.ref() works on all kinds of callables. Usage is same as weakref.ref().

Parameters:
  • c (callable) - A callable that the weak reference should point at.
  • callback (callable) - Callback called when the callable is collected (freed).
Returns: weakref
A weak callable reference.