Robot Framework Integrated Development Environment (RIDE)
robottypes3.py
Go to the documentation of this file.
1
# Copyright 2008-2015 Nokia Networks
2
# Copyright 2016- Robot Framework Foundation
3
#
4
# Licensed under the Apache License, Version 2.0 (the "License");
5
# you may not use this file except in compliance with the License.
6
# You may obtain a copy of the License at
7
#
8
# http://www.apache.org/licenses/LICENSE-2.0
9
#
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
15
try
:
16
from
collections
import
Mapping, UserString
17
except
ImportError:
18
from
collections.abc
import
Mapping
# Python 3.10
19
from
collections
import
UserString
20
21
from
io
import
IOBase
22
23
from
.platform
import
RERAISED_EXCEPTIONS
24
25
26
def
is_integer
(item):
27
return
isinstance(item, int)
28
29
30
def
is_number
(item):
31
return
isinstance(item, (int, float))
32
33
34
def
is_bytes
(item):
35
return
isinstance(item, (bytes, bytearray))
36
37
38
def
is_string
(item):
39
return
isinstance(item, str)
40
41
42
def
is_unicode
(item):
43
return
isinstance(item, str)
44
45
46
def
is_tuple
(item):
47
return
isinstance(item, tuple)
48
49
50
def
is_list_like
(item):
51
if
isinstance(item, (str, bytes, bytearray, UserString, IOBase)):
52
return
False
53
try
:
54
iter(item)
55
except
RERAISED_EXCEPTIONS:
56
raise
57
except
:
58
return
False
59
else
:
60
return
True
61
62
63
def
is_dict_like
(item):
64
return
isinstance(item, Mapping)
65
66
67
def
type_name
(item):
68
if
isinstance(item, IOBase):
69
return
'file'
70
cls = item.__class__
if
hasattr(item,
'__class__'
)
else
type
(item)
71
named_types = {str:
'string'
, bool:
'boolean'
, int:
'integer'
,
72
type
(
None
):
'None'
, dict:
'dictionary'
, type:
'class'
}
73
return
named_types.get(cls, cls.__name__)
type
robotide.lib.robot.utils.robottypes3.is_unicode
def is_unicode(item)
Definition:
robottypes3.py:42
robotide.lib.robot.utils.robottypes3.is_bytes
def is_bytes(item)
Definition:
robottypes3.py:34
robotide.lib.robot.utils.robottypes3.is_number
def is_number(item)
Definition:
robottypes3.py:30
robotide.lib.robot.utils.robottypes3.is_integer
def is_integer(item)
Definition:
robottypes3.py:26
robotide.lib.robot.utils.robottypes3.is_list_like
def is_list_like(item)
Definition:
robottypes3.py:50
robotide.lib.robot.utils.robottypes3.type_name
def type_name(item)
Definition:
robottypes3.py:67
robotide.lib.robot.utils.robottypes3.is_dict_like
def is_dict_like(item)
Definition:
robottypes3.py:63
robotide.lib.robot.utils.robottypes3.is_string
def is_string(item)
Definition:
robottypes3.py:38
robotide.lib.robot.utils.robottypes3.is_tuple
def is_tuple(item)
Definition:
robottypes3.py:46
src
robotide
lib
robot
utils
robottypes3.py
Generated by
1.9.1