Bumps OVS version to 2.8 for OVN
[apex.git] / lib / python / apex / common / utils.py
1 ##############################################################################
2 # Copyright (c) 2016 Tim Rozet (trozet@redhat.com) and others.
3 #
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9
10 import yaml
11
12
13 def str2bool(var):
14     if isinstance(var, bool):
15         return var
16     else:
17         return var.lower() in ("true", "yes")
18
19
20 def parse_yaml(yaml_file):
21     with open(yaml_file) as f:
22         parsed_dict = yaml.safe_load(f)
23         return parsed_dict
24
25
26 def write_str(bash_str, path=None):
27     if path:
28         with open(path, 'w') as file:
29             file.write(bash_str)
30     else:
31         print(bash_str)