MCPcopy Create free account
hub / github.com/PageBot/PageBot / asIntOrFloat

Function asIntOrFloat

Lib/pagebot/toolbox/transformer.py:158–173  ·  view source on GitHub ↗

Answers value converted to int if same value, otherwise answer float. >>> asIntOrFloat(100.00) 100 >>> asIntOrFloat(100) 100 >>> asIntOrFloat(100.12) 100.12

(value)

Source from the content-addressed store, hash-verified

156 return default
157
158def asIntOrFloat(value):
159 """Answers value converted to int if same value, otherwise answer float.
160
161 >>> asIntOrFloat(100.00)
162 100
163 >>> asIntOrFloat(100)
164 100
165 >>> asIntOrFloat(100.12)
166 100.12
167 """
168 if value == math.inf:
169 value = XXXL
170 iValue = int(value)
171 if iValue == value:
172 return iValue
173 return value
174
175def asFormatted(value, default=None, hasFormat=None):
176 """Answers the formatted string of value. Use the format string if defined.

Callers 15

__repr__Method · 0.90
_get_ptMethod · 0.90
_get_pxMethod · 0.90
_get_inchMethod · 0.90
_get_pMethod · 0.90
_get_cmMethod · 0.90
_get_mmMethod · 0.90
_get_rvMethod · 0.90
__int__Method · 0.90
_get_pMethod · 0.90
__repr__Method · 0.90
__repr__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected