1
1
from os import uname
2
2
3
- class ComposableFunction (object ):
4
- def __init__ (self , function ):
5
- self .func = function
6
-
7
- def __call__ (self , * args , ** kwargs ):
8
- return self .func (* args , ** kwargs )
9
-
10
- def __and__ (self , f ):
11
- return ComposableFunction (lambda * args , ** kwargs : self (* args , ** kwargs ) and f (* args , ** kwargs ))
12
-
13
- def __or__ (self , f ):
14
- return ComposableFunction (lambda * args , ** kwargs : self (* args , ** kwargs ) or f (* args , ** kwargs ))
15
-
16
3
17
4
def check_all (* callables ):
18
5
def check (** kwargs ):
19
6
return all (c (** kwargs ) for c in callables )
20
- return ComposableFunction ( check )
7
+ return check
21
8
22
9
23
10
def check_any (* callables ):
24
11
def check (** kwargs ):
25
12
return any (c (** kwargs ) for c in callables )
26
- return ComposableFunction ( check )
13
+ return check
27
14
28
15
29
16
def is_platform (platform ):
30
17
def is_x (** kwargs ):
31
18
return uname ()[0 ] == platform
32
- return ComposableFunction ( is_x )
19
+ return is_x
33
20
34
21
is_linux = is_platform ('Linux' )
35
22
is_darwin = is_platform ('Darwin' )
@@ -38,41 +25,41 @@ def is_x(**kwargs):
38
25
def is_arch (xarch ):
39
26
def is_x (arch , ** kwargs ):
40
27
return arch .arch == xarch
41
- return ComposableFunction ( is_x )
28
+ return is_x
42
29
43
30
44
31
def is_api_gt (apiver ):
45
32
def is_x (recipe , ** kwargs ):
46
33
return recipe .ctx .android_api > apiver
47
- return ComposableFunction ( is_x )
34
+ return is_x
48
35
49
36
50
37
def is_api_gte (apiver ):
51
38
def is_x (recipe , ** kwargs ):
52
39
return recipe .ctx .android_api >= apiver
53
- return ComposableFunction ( is_x )
40
+ return is_x
54
41
55
42
56
43
def is_api_lt (apiver ):
57
44
def is_x (recipe , ** kwargs ):
58
45
return recipe .ctx .android_api < apiver
59
- return ComposableFunction ( is_x )
46
+ return is_x
60
47
61
48
62
49
def is_api_lte (apiver ):
63
50
def is_x (recipe , ** kwargs ):
64
51
return recipe .ctx .android_api <= apiver
65
- return ComposableFunction ( is_x )
52
+ return is_x
66
53
67
54
68
55
def is_api (apiver ):
69
56
def is_x (recipe , ** kwargs ):
70
57
return recipe .ctx .android_api == apiver
71
- return ComposableFunction ( is_x )
58
+ return is_x
72
59
73
60
74
61
def will_build (recipe_name ):
75
62
def will (recipe , ** kwargs ):
76
63
return recipe_name in recipe .ctx .recipe_build_order
77
- return ComposableFunction ( will )
64
+ return will
78
65
0 commit comments