Robot Framework Integrated Development Environment (RIDE)
robottypes.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 
16 from .platform import PY2
17 
18 
19 if PY2:
20  from .robottypes2 import (is_bytes, is_dict_like, is_integer, is_list_like,
21  is_number, is_string, is_unicode, is_tuple, type_name)
22  unicode = unicode
23 
24 else:
25  from .robottypes3 import (is_bytes, is_dict_like, is_integer, is_list_like,
26  is_number, is_string, is_unicode, is_tuple, type_name)
27  unicode = str
28 
29 
30 TRUE_STRINGS = {'TRUE', 'YES', 'ON', '1'}
31 FALSE_STRINGS = {'FALSE', 'NO', 'OFF', '0', 'NONE', ''}
32 
33 
34 
49 def is_truthy(item):
50  if is_string(item):
51  return item.upper() not in FALSE_STRINGS
52  return bool(item)
53 
54 
55 
56 def is_falsy(item):
57  return not is_truthy(item)
def is_truthy(item)
Returns True or False depending is the item considered true or not.
Definition: robottypes.py:49
def is_falsy(item)
Opposite of :func:is_truthy.
Definition: robottypes.py:56