Files
openvino/model-optimizer/mo/utils/str_to.py
Alexey Suhov 6478f1742a Align copyright notice in python scripts (CVS-51320) (#4974)
* Align copyright notice in python scripts (CVS-51320)
2021-03-26 17:54:28 +03:00

26 lines
772 B
Python

# Copyright (C) 2018-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
class StrTo(object):
@staticmethod
def tuple(type_of_elements: type, string: str):
if type_of_elements == int:
string = string.replace('L', '')
return tuple(type_of_elements(x) for x in string[1:-1].split(',') if x != '')
@staticmethod
def list(string: str, type_of_elements: type, sep: str):
result = string.split(sep)
result = [type_of_elements(x) for x in result]
return result
@staticmethod
def bool(val: str):
if val.lower() == "false":
return False
elif val.lower() == "true":
return True
else:
raise ValueError("Value is not boolean: " + val)