VirtualMailManager/pycompat/__init__.py
author martin f. krafft <madduck@madduck.net>
Fri, 13 Apr 2012 23:24:12 +0200
branchv0.6.x
changeset 532 2bb40aaef94e
parent 366 d6573da35b5f
child 568 14abdd04ddf5
permissions -rw-r--r--
Modify userinfo output to indicate when domain defaults are displayed When Account instances reference NULL tid/qid/ssid, the data must come from the associated domain, and this should be indicated. For transport and services, this is easy to do as the string passed in the info dict can simply be modified. For quotalimit, however, another method must be used due to the CLI-side formatting. All approaches use a common formatter outsourced to the common.py file.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
219
0b6ce895e1dc VMM/pycompat: added to the repository. Provides all() for Py24.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     1
# -*- coding: UTF-8 -*-
366
d6573da35b5f Updated copyright notices to include the year 2011.
Pascal Volk <neverseen@users.sourceforge.net>
parents: 260
diff changeset
     2
# Copyright (c) 2010 - 2011, Pascal Volk
219
0b6ce895e1dc VMM/pycompat: added to the repository. Provides all() for Py24.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     3
# See COPYING for distribution information.
0b6ce895e1dc VMM/pycompat: added to the repository. Provides all() for Py24.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     4
0b6ce895e1dc VMM/pycompat: added to the repository. Provides all() for Py24.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     5
"""
0b6ce895e1dc VMM/pycompat: added to the repository. Provides all() for Py24.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     6
    VirtualMailManager.pycompat
0b6ce895e1dc VMM/pycompat: added to the repository. Provides all() for Py24.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     7
0b6ce895e1dc VMM/pycompat: added to the repository. Provides all() for Py24.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     8
    VirtualMailManager's compatibility stuff for Python 2.4
0b6ce895e1dc VMM/pycompat: added to the repository. Provides all() for Py24.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
     9
"""
0b6ce895e1dc VMM/pycompat: added to the repository. Provides all() for Py24.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    10
0b6ce895e1dc VMM/pycompat: added to the repository. Provides all() for Py24.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    11
# http://docs.python.org/library/functions.html#all
0b6ce895e1dc VMM/pycompat: added to the repository. Provides all() for Py24.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    12
try:
0b6ce895e1dc VMM/pycompat: added to the repository. Provides all() for Py24.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    13
    all = all
0b6ce895e1dc VMM/pycompat: added to the repository. Provides all() for Py24.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    14
except NameError:
0b6ce895e1dc VMM/pycompat: added to the repository. Provides all() for Py24.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    15
    def all(iterable):
0b6ce895e1dc VMM/pycompat: added to the repository. Provides all() for Py24.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    16
        """Return True if all elements of the *iterable* are true
0b6ce895e1dc VMM/pycompat: added to the repository. Provides all() for Py24.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    17
        (or if the iterable is empty).
0b6ce895e1dc VMM/pycompat: added to the repository. Provides all() for Py24.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    18
0b6ce895e1dc VMM/pycompat: added to the repository. Provides all() for Py24.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    19
        """
0b6ce895e1dc VMM/pycompat: added to the repository. Provides all() for Py24.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    20
        for element in iterable:
0b6ce895e1dc VMM/pycompat: added to the repository. Provides all() for Py24.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    21
            if not element:
0b6ce895e1dc VMM/pycompat: added to the repository. Provides all() for Py24.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    22
                return False
0b6ce895e1dc VMM/pycompat: added to the repository. Provides all() for Py24.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff changeset
    23
        return True
224
7e9874a50d92 VMM/pycompat: added function any() for Python 2.4
Pascal Volk <neverseen@users.sourceforge.net>
parents: 219
diff changeset
    24
7e9874a50d92 VMM/pycompat: added function any() for Python 2.4
Pascal Volk <neverseen@users.sourceforge.net>
parents: 219
diff changeset
    25
7e9874a50d92 VMM/pycompat: added function any() for Python 2.4
Pascal Volk <neverseen@users.sourceforge.net>
parents: 219
diff changeset
    26
# http://docs.python.org/library/functions.html#any
7e9874a50d92 VMM/pycompat: added function any() for Python 2.4
Pascal Volk <neverseen@users.sourceforge.net>
parents: 219
diff changeset
    27
try:
7e9874a50d92 VMM/pycompat: added function any() for Python 2.4
Pascal Volk <neverseen@users.sourceforge.net>
parents: 219
diff changeset
    28
    any = any
7e9874a50d92 VMM/pycompat: added function any() for Python 2.4
Pascal Volk <neverseen@users.sourceforge.net>
parents: 219
diff changeset
    29
except NameError:
7e9874a50d92 VMM/pycompat: added function any() for Python 2.4
Pascal Volk <neverseen@users.sourceforge.net>
parents: 219
diff changeset
    30
    def any(iterable):
7e9874a50d92 VMM/pycompat: added function any() for Python 2.4
Pascal Volk <neverseen@users.sourceforge.net>
parents: 219
diff changeset
    31
        """Return True if any element of the *iterable* is true.  If the
7e9874a50d92 VMM/pycompat: added function any() for Python 2.4
Pascal Volk <neverseen@users.sourceforge.net>
parents: 219
diff changeset
    32
        iterable is empty, return False.
7e9874a50d92 VMM/pycompat: added function any() for Python 2.4
Pascal Volk <neverseen@users.sourceforge.net>
parents: 219
diff changeset
    33
7e9874a50d92 VMM/pycompat: added function any() for Python 2.4
Pascal Volk <neverseen@users.sourceforge.net>
parents: 219
diff changeset
    34
        """
7e9874a50d92 VMM/pycompat: added function any() for Python 2.4
Pascal Volk <neverseen@users.sourceforge.net>
parents: 219
diff changeset
    35
        for element in iterable:
7e9874a50d92 VMM/pycompat: added function any() for Python 2.4
Pascal Volk <neverseen@users.sourceforge.net>
parents: 219
diff changeset
    36
            if element:
7e9874a50d92 VMM/pycompat: added function any() for Python 2.4
Pascal Volk <neverseen@users.sourceforge.net>
parents: 219
diff changeset
    37
                return True
7e9874a50d92 VMM/pycompat: added function any() for Python 2.4
Pascal Volk <neverseen@users.sourceforge.net>
parents: 219
diff changeset
    38
        return False