Esempio n. 1
0
    def __init__(self,
                 functor,
                 requires,
                 name=None,
                 provides=None,
                 auto_extract=True,
                 rebind=None,
                 inject=None):

        if not six.callable(functor):
            raise ValueError("Function to use for map must be callable")

        f_args = reflection.get_callable_args(functor)
        if len(f_args) != 1:
            raise ValueError("%s arguments were provided. Map functor must "
                             "take exactly 1 argument." % len(f_args))

        if not misc.is_iterable(requires):
            raise TypeError("%s type was provided for requires. Requires "
                            "must be an iterable." % type(requires))

        if name is None:
            name = reflection.get_callable_name(functor)
        super(MapFunctorTask, self).__init__(name=name,
                                             provides=provides,
                                             inject=inject,
                                             requires=requires,
                                             rebind=rebind,
                                             auto_extract=auto_extract)

        self._functor = functor
Esempio n. 2
0
    def __init__(self, functor, requires, name=None, provides=None,
                 auto_extract=True, rebind=None, inject=None):

        if not six.callable(functor):
            raise ValueError("Function to use for reduce must be callable")

        f_args = reflection.get_callable_args(functor)
        if len(f_args) != 2:
            raise ValueError("%s arguments were provided. Reduce functor "
                             "must take exactly 2 arguments." % len(f_args))

        if not misc.is_iterable(requires):
            raise TypeError("%s type was provided for requires. Requires "
                            "must be an iterable." % type(requires))

        if len(requires) < 2:
            raise ValueError("%s elements were provided. Requires must have "
                             "at least 2 elements." % len(requires))

        if name is None:
            name = reflection.get_callable_name(functor)
        super(ReduceFunctorTask, self).__init__(name=name, provides=provides,
                                                inject=inject)

        self._functor = functor

        self._build_arg_mapping(executor=self.execute, requires=requires,
                                rebind=rebind, auto_extract=auto_extract)
Esempio n. 3
0
    def __init__(self, functor, requires, name=None, provides=None,
                 auto_extract=True, rebind=None, inject=None):

        if not six.callable(functor):
            raise ValueError("Function to use for reduce must be callable")

        f_args = reflection.get_callable_args(functor)
        if len(f_args) != 2:
            raise ValueError("%s arguments were provided. Reduce functor "
                             "must take exactly 2 arguments." % len(f_args))

        if not misc.is_iterable(requires):
            raise TypeError("%s type was provided for requires. Requires "
                            "must be an iterable." % type(requires))

        if len(requires) < 2:
            raise ValueError("%s elements were provided. Requires must have "
                             "at least 2 elements." % len(requires))

        if name is None:
            name = reflection.get_callable_name(functor)
        super(ReduceFunctorTask, self).__init__(name=name,
                                                provides=provides,
                                                inject=inject,
                                                requires=requires,
                                                rebind=rebind,
                                                auto_extract=auto_extract)

        self._functor = functor
Esempio n. 4
0
    def __init__(self, functor, requires, name=None, provides=None,
                 auto_extract=True, rebind=None, inject=None):

        if not six.callable(functor):
            raise ValueError("Function to use for map must be callable")

        f_args = reflection.get_callable_args(functor)
        if len(f_args) != 1:
            raise ValueError("%s arguments were provided. Map functor must "
                             "take exactly 1 argument." % len(f_args))

        if not misc.is_iterable(requires):
            raise TypeError("%s type was provided for requires. Requires "
                            "must be an iterable." % type(requires))

        if name is None:
            name = reflection.get_callable_name(functor)
        super(MapFunctorTask, self).__init__(name=name, provides=provides,
                                             inject=inject)

        self._functor = functor

        self._build_arg_mapping(executor=self.execute, requires=requires,
                                rebind=rebind, auto_extract=auto_extract)
Esempio n. 5
0
 def test_dict(self):
     self.assertTrue(misc.is_iterable(dict()))
Esempio n. 6
0
 def test_tuple(self):
     self.assertTrue(misc.is_iterable(tuple()))
Esempio n. 7
0
 def test_list(self):
     self.assertTrue(misc.is_iterable(list()))
Esempio n. 8
0
 def test_string_types(self):
     self.assertFalse(misc.is_iterable('string'))
     self.assertFalse(misc.is_iterable(u'string'))
Esempio n. 9
0
 def test_dict(self):
     self.assertTrue(misc.is_iterable(dict()))
Esempio n. 10
0
 def test_tuple(self):
     self.assertTrue(misc.is_iterable(tuple()))
Esempio n. 11
0
 def test_list(self):
     self.assertTrue(misc.is_iterable(list()))
Esempio n. 12
0
 def test_string_types(self):
     self.assertFalse(misc.is_iterable('string'))
     self.assertFalse(misc.is_iterable(u'string'))