コード例 #1
0
ファイル: task.py プロジェクト: homolkad/deb-python-taskflow
    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
コード例 #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)
コード例 #3
0
ファイル: task.py プロジェクト: paperandsoap/taskflow
    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
コード例 #4
0
ファイル: task.py プロジェクト: Dynavisor/taskflow
    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)
コード例 #5
0
 def test_dict(self):
     self.assertTrue(misc.is_iterable(dict()))
コード例 #6
0
 def test_tuple(self):
     self.assertTrue(misc.is_iterable(tuple()))
コード例 #7
0
 def test_list(self):
     self.assertTrue(misc.is_iterable(list()))
コード例 #8
0
 def test_string_types(self):
     self.assertFalse(misc.is_iterable('string'))
     self.assertFalse(misc.is_iterable(u'string'))
コード例 #9
0
ファイル: test_utils.py プロジェクト: junneyang/taskflow
 def test_dict(self):
     self.assertTrue(misc.is_iterable(dict()))
コード例 #10
0
ファイル: test_utils.py プロジェクト: junneyang/taskflow
 def test_tuple(self):
     self.assertTrue(misc.is_iterable(tuple()))
コード例 #11
0
ファイル: test_utils.py プロジェクト: junneyang/taskflow
 def test_list(self):
     self.assertTrue(misc.is_iterable(list()))
コード例 #12
0
ファイル: test_utils.py プロジェクト: junneyang/taskflow
 def test_string_types(self):
     self.assertFalse(misc.is_iterable('string'))
     self.assertFalse(misc.is_iterable(u'string'))