Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(1)  |  Call(1)  |  Derive(0)  |  Import(0)
Define a preprocessor to run after the arguments are parsed and
before the function is executed, when running in console script
mode.

:param preproc: The callable, which will be passed the Namespace
                object generated by argparse.

        def add_preprocessor(preproc):
    """
    Define a preprocessor to run after the arguments are parsed and
    before the function is executed, when running in console script
    mode.

    :param preproc: The callable, which will be passed the Namespace
                    object generated by argparse.
    """

    def decorator(func):
        func = ScriptAdaptor._wrap(func)
        func._add_preprocessor(preproc)
        return func
    return decorator
        


src/t/u/turnstile-HEAD/tests/unit/test_tools.py   turnstile(Download)
    def test_decorator(self, mock_wrap):
        decorator = tools.add_preprocessor('preproc')
 
        self.assertTrue(callable(decorator))
        self.assertFalse(mock_wrap.called)