Esempio n. 1
0
 def _fail_extra_arg():
     backports.next((x * 2 for x in range(3, 5) if x > 100),
                    ("default", "extra arg"))
Esempio n. 2
0
 def path_searcher(target, extra_dirs=extra_paths):
     matches = itertools.ifilter(
         target_predicate, path_generator(target, extra_dirs, **kwargs))
     paths = itertools.imap(target_normalizer, matches)
     return next(paths, '')
Esempio n. 3
0
 def test_next(self):
     self.assertEquals(backports.next((x * 2 for x in range(3, 5))), 6)
     self.assertEquals(
         backports.next((x * 2 for x in range(3, 5) if x > 100), "default"),
         "default")
Esempio n. 4
0
#
#  The full GNU General Public License is included in this distribution in
#  the file called "COPYING".

import os
import itertools
import logging
from glob import glob

try:
    import autotest.common as common
except ImportError:
    import common

try:
    next(iter(''), '')
except NameError:
    from autotest.client.shared.backports import next

# One day, when this module grows up, it might actually try to fix things.
# 'apt-cache search | apt-get install' ... or a less terrifying version of
# the same. With added distro-independant pixie dust.

COMMON_BIN_PATHS = ("/usr/libexec", "/usr/local/sbin", "/usr/local/bin",
                    "/usr/sbin", "/usr/bin", "/sbin", "/bin")


def exception_when_false_wrapper(func, exception_class,
                                 value_error_message_template):
    """
    Wrap a function to raise an exception when the return value is not True.
Esempio n. 5
0
 def path_searcher(target, extra_dirs=extra_paths):
     matches = itertools.ifilter(
         target_predicate, path_generator(target, extra_dirs, **kwargs))
     paths = itertools.imap(target_normalizer, matches)
     return next(paths, '')
Esempio n. 6
0
#  The full GNU General Public License is included in this distribution in
#  the file called "COPYING".


import itertools
import logging
import os
from glob import glob

try:
    import autotest.common as common  # pylint: disable=W0611
except ImportError:
    import common  # pylint: disable=W0611

try:
    next(iter(''), '')
except NameError:
    from autotest.client.shared.backports import next

# One day, when this module grows up, it might actually try to fix things.
# 'apt-cache search | apt-get install' ... or a less terrifying version of
# the same. With added distro-independant pixie dust.

COMMON_BIN_PATHS = ("/usr/libexec", "/usr/local/sbin", "/usr/local/bin",
                    "/usr/sbin", "/usr/bin", "/sbin", "/bin")


def exception_when_false_wrapper(func, exception_class, value_error_message_template):
    """
    Wrap a function to raise an exception when the return value is not True.
 def _fail_extra_arg():
     backports.next((x * 2 for x in range(3, 5) if x > 100),
                    ("default", "extra arg"))
 def test_next(self):
     self.assertEquals(backports.next((x * 2 for x in range(3, 5))), 6)
     self.assertEquals(backports.next((x * 2 for x in range(3, 5) if x > 100),
                                      "default"), "default")