File size: 1,134 Bytes
f4952b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""A module of coroutines for the coroutine pairs of this catalog.

Every function here is a coroutine on purpose. The cards that vouch for coroutines
carry a pair over these names, so the claim is proven over an async def and not just
stated; the cards that do not vouch for coroutines have to say what they answer when
one of these functions is named as their target.
"""


async def render_page(url, width=80):
    return str(url).ljust(width)


async def sized(n: int = 4) -> int:
    return n


async def gather(seed, tags=[]):
    return tags + [seed]


async def plain(value):
    return value


async def check_name(name):
    assert name
    return name


async def check_after(name):
    shown = name or "unnamed"
    assert shown
    return shown


async def describe(value):
    if value == None:
        return "nothing"
    return str(value)


async def present(value):
    if value is not None:
        return str(value)
    return "nothing"


async def word_total(items):
    if len(items) == 0:
        return 0
    return sum(len(item.split()) for item in items)


async def item_count(items):
    return len(items)