24 # memory size configuration stuff
25 def to_integer(value
):
26 if not isinstance(value
, str):
28 elif value
.endswith('Ei'):
29 result
= int(value
[:-2]) * exbi
30 elif value
.endswith('Pi'):
31 result
= int(value
[:-2]) * pebi
32 elif value
.endswith('Ti'):
33 result
= int(value
[:-2]) * tebi
34 elif value
.endswith('Gi'):
35 result
= int(value
[:-2]) * gibi
36 elif value
.endswith('Mi'):
37 result
= int(value
[:-2]) * mebi
38 elif value
.endswith('ki'):
39 result
= int(value
[:-2]) * kibi
40 elif value
.endswith('E'):
41 result
= int(value
[:-1]) * exa
42 elif value
.endswith('P'):
43 result
= int(value
[:-1]) * peta
44 elif value
.endswith('T'):
45 result
= int(value
[:-1]) * tera
46 elif value
.endswith('G'):
47 result
= int(value
[:-1]) * giga
48 elif value
.endswith('M'):
49 result
= int(value
[:-1]) * mega
50 elif value
.endswith('k'):
51 result
= int(value
[:-1]) * kilo
52 elif value
.endswith('m'):
53 result
= int(value
[:-1]) * milli
54 elif value
.endswith('u'):
55 result
= int(value
[:-1]) * micro
56 elif value
.endswith('n'):
57 result
= int(value
[:-1]) * nano
58 elif value
.endswith('p'):
59 result
= int(value
[:-1]) * pico
60 elif value
.endswith('f'):
61 result
= int(value
[:-1]) * femto
75 if t
== int or t
== long:
80 if val
== "true" or val
== "t" or val
== "yes" or val
== "y":
82 elif val
== "false" or val
== "f" or val
== "no" or val
== "n":
85 return to_integer(val
) != 0
87 def to_frequency(value
):
88 if not isinstance(value
, str):
90 elif value
.endswith('THz'):
91 result
= float(value
[:-3]) * tera
92 elif value
.endswith('GHz'):
93 result
= float(value
[:-3]) * giga
94 elif value
.endswith('MHz'):
95 result
= float(value
[:-3]) * mega
96 elif value
.endswith('kHz'):
97 result
= float(value
[:-3]) * kilo
98 elif value
.endswith('Hz'):
99 result
= float(value
[:-2])
101 result
= float(value
)
105 def to_latency(value
):
106 if not isinstance(value
, str):
107 result
= float(value
)
108 elif value
.endswith('c'):
109 result
= float(value
[:-1])
110 elif value
.endswith('ps'):
111 result
= float(value
[:-2]) * pico
112 elif value
.endswith('ns'):
113 result
= float(value
[:-2]) * nano
114 elif value
.endswith('us'):
115 result
= float(value
[:-2]) * micro
116 elif value
.endswith('ms'):
117 result
= float(value
[:-2]) * milli
118 elif value
.endswith('s'):
119 result
= float(value
[:-1])
121 result
= float(value
)
125 def to_network_bandwidth(value
):
126 if not isinstance(value
, str):
127 result
= float(value
)
128 elif value
.endswith('Tbps'):
129 result
= float(value
[:-3]) * tera
130 elif value
.endswith('Gbps'):
131 result
= float(value
[:-3]) * giga
132 elif value
.endswith('Mbps'):
133 result
= float(value
[:-3]) * mega
134 elif value
.endswith('kbps'):
135 result
= float(value
[:-3]) * kilo
136 elif value
.endswith('bps'):
137 result
= float(value
[:-2])
139 result
= float(value
)
143 def to_memory_bandwidth(value
):
144 if not isinstance(value
, str):
146 elif value
.endswith('PB/s'):
147 result
= int(value
[:-4]) * pebi
148 elif value
.endswith('TB/s'):
149 result
= int(value
[:-4]) * tebi
150 elif value
.endswith('GB/s'):
151 result
= int(value
[:-4]) * gibi
152 elif value
.endswith('MB/s'):
153 result
= int(value
[:-4]) * mebi
154 elif value
.endswith('kB/s'):
155 result
= int(value
[:-4]) * kibi
156 elif value
.endswith('B/s'):
157 result
= int(value
[:-3])
163 def to_memory_size(value
):
164 if not isinstance(value
, str):
166 elif value
.endswith('PB'):
167 result
= int(value
[:-2]) * pebi
168 elif value
.endswith('TB'):
169 result
= int(value
[:-2]) * tebi
170 elif value
.endswith('GB'):
171 result
= int(value
[:-2]) * gibi
172 elif value
.endswith('MB'):
173 result
= int(value
[:-2]) * mebi
174 elif value
.endswith('kB'):
175 result
= int(value
[:-2]) * kibi
176 elif value
.endswith('B'):
177 result
= int(value
[:-1])