File tree 1 file changed +47
-0
lines changed
1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ __author__ = "ipetrash"
5
+
6
+
7
+ import asyncio
8
+ import functools
9
+
10
+
11
+ def makebold (func ):
12
+ @functools .wraps (func )
13
+ async def wrapped (* args , ** kwargs ):
14
+ return "<b>" + await func (* args , ** kwargs ) + "</b>"
15
+
16
+ return wrapped
17
+
18
+
19
+ def makeitalic (func ):
20
+ @functools .wraps (func )
21
+ async def wrapped (* args , ** kwargs ):
22
+ return "<i>" + await func (* args , ** kwargs ) + "</i>"
23
+
24
+ return wrapped
25
+
26
+
27
+ def upper (func ):
28
+ @functools .wraps (func )
29
+ async def wrapped (* args , ** kwargs ):
30
+ return (await func (* args , ** kwargs )).upper ()
31
+
32
+ return wrapped
33
+
34
+
35
+ @makebold
36
+ @makeitalic
37
+ @upper
38
+ async def hello (text ):
39
+ return text
40
+
41
+
42
+ loop = asyncio .new_event_loop ()
43
+
44
+ print (loop .run_until_complete (hello ("Hello World!" )))
45
+ # <b><i>HELLO WORLD!</i></b>
46
+
47
+ assert loop .run_until_complete (hello ("Hello World!" )) == "<b><i>HELLO WORLD!</i></b>"
You can’t perform that action at this time.
0 commit comments