Yet Another WebIOPi+
Main Page
Related Pages
Packages
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Macros
Pages
python
webiopi
utils
types.py
Go to the documentation of this file.
1
import
json
2
from
webiopi.utils
import
logger
3
4
M_PLAIN =
"text/plain"
5
M_JSON =
"application/json"
6
7
def
jsonDumps
(obj):
8
if
logger.debugEnabled():
9
return
json.dumps(obj, sort_keys=
True
, indent=4, separators=(
','
,
': '
))
10
else
:
11
return
json.dumps(obj)
12
13
def
str2bool
(value):
14
return
(value ==
"1"
)
or
(value ==
"true"
)
or
(value ==
"True"
)
or
(value ==
"yes"
)
or
(value ==
"Yes"
)
15
16
def
toint
(value):
17
if
isinstance(value, str):
18
if
value.startswith(
"0b"
):
19
return
int(value, 2)
20
elif
value.startswith(
"0x"
):
21
return
int(value, 16)
22
else
:
23
return
int(value)
24
return
value
25
26
27
def
signInteger
(value, bitcount):
28
if
value & (1<<(bitcount-1)):
29
return
value - (1<<bitcount)
30
return
value
webiopi.utils.types.jsonDumps
def jsonDumps
Definition:
types.py:7
webiopi.utils.types.str2bool
def str2bool
Definition:
types.py:13
webiopi.utils
Definition:
__init__.py:1
webiopi.utils.types.signInteger
def signInteger
Definition:
types.py:27
webiopi.utils.types.toint
def toint
Definition:
types.py:16
Generated on Sat Sep 10 2016 09:37:20 for Yet Another WebIOPi+ by
1.8.8