Peano
Loading...
Searching...
No Matches
Helper.py
Go to the documentation of this file.
1# This file is part of the Peano project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
3import os
4
5from .Overwrite import Overwrite
6
7def write_file(overwrite,overwrite_is_default,full_qualified_filename):
8 """
9 overwrite is of type Overwrite and is what the user passes in
10 overwrite_is_default is a boolean
11 """
12 if overwrite==Overwrite.Always:
13 return True
14 elif overwrite==Overwrite.Never and os.path.exists(full_qualified_filename):
15 return False
16 elif overwrite==Overwrite.Never and not os.path.exists(full_qualified_filename):
17 return True
18 elif overwrite==Overwrite.Default:
19 if not overwrite_is_default and os.path.exists(full_qualified_filename):
20 return False
21 else:
22 return True
23 else:
24 print("Error: undefined overwrite strategy")
25 return True
write_file(overwrite, overwrite_is_default, full_qualified_filename)
overwrite is of type Overwrite and is what the user passes in overwrite_is_default is a boolean
Definition Helper.py:7