Beispiel #1
0
    async def liteval(expr: str, verbose: Optional[bool] = False) -> int:
        """Evaluation of a Python literal."""
        app = current_app()

        if verbose:
            app.io.info('Verbose mode is on!')

        app.io.raw(ast.literal_eval(expr))
        return 0
        async def handle_A_and_B(ecx):
            app = current_app()

            if isinstance(ecx, ExcA):
                app.bag.exc_list.append('A')
            elif isinstance(ecx, ExcB):
                app.bag.exc_list.append('B')
            else:
                assert False, 'this should not happen'
Beispiel #3
0
 async def before_cd_hook_one(path: PagePath):
     self.assertIsInstance(path, PagePath)
     self.assertEqual(path, '/')
     current_app().bag.values.append(1)
Beispiel #4
0
 async def after_not_real():
     current_app().bag.after_hook_did_fire = True
Beispiel #5
0
 async def before_not_real():
     current_app().bag.before_hook_did_fire = True
 async def catch_all_hook(exc):
     current_app().bag.lask_hook = 'D'
     self.assertIsInstance(exc, ExcD)
     self.assertEqual(exc.args[0], 'D')
Beispiel #7
0
 def inc_prompt():
     inner_app_ref = current_app()
     inner_app_ref.bag.counter += 1
     return f'{inner_app_ref.bag.counter}> '
Beispiel #8
0
 async def before_my_command(x: int):
     current_app().bag.before.append(x)
 async def hook_A(exc):
     current_app().bag.last_hook = 'A'
     self.assertIsInstance(exc, ExcA)
     self.assertEqual(exc.args[0], 'A')
Beispiel #10
0
 async def hook_ExcExit(exc: ExcExit):
     self.assertIsInstance(exc, ExcExit)
     current_app().bag.did_hook_on_exit = True
Beispiel #11
0
 async def hook_exc_after(exc: ExcAfter):
     self.assertIsInstance(exc, ExcAfter)
     current_app().bag.did_hook_after = True
Beispiel #12
0
 async def hook_exc_before(exc: ExcBefore):
     self.assertIsInstance(exc, ExcBefore)
     current_app().bag.did_hook_before = True
Beispiel #13
0
 async def hook_exc_two(exc):
     app = current_app()
     app.bag.marker = 'two'
Beispiel #14
0
 async def hook_exc_one(exc):
     app = current_app()
     app.bag.marker = 'one'
Beispiel #15
0
 async def inc_counter():
     inner_app_ref = current_app()
     inner_app_ref.bag.init_count += 1
Beispiel #16
0
 async def after_cd_hook_two(path: PagePath):
     self.assertIsInstance(path, PagePath)
     self.assertEqual(path, '/')
     current_app().bag.values.append(4)
Beispiel #17
0
 async def my_command(x: int):
     current_app().bag.values.append(x)
Beispiel #18
0
 async def hook_B(exc):
     current_app().bag.last_hook = 'B'
     self.assertIsInstance(exc, ExcB)
     self.assertEqual(exc.args[0], 'B')
Beispiel #19
0
 async def after_my_command(x: int):
     current_app().bag.after.append(x)
Beispiel #20
0
 async def hook_C(exc):
     current_app().bag.last_hook = 'C'
     self.assertIsInstance(exc, ExcC)
     self.assertEqual(exc.args[0], 'C')