]>
git.ipfire.org Git - nitsi.git/blob - src/nitsi/settings.py
b2dd71da7b42f180d1bc7860383f3239d22e3af4
6 logger
= logging
.getLogger("nitsi.settings")
8 class SettingsException(Exception):
9 def __init__(self
, message
):
10 self
.message
= message
12 def settings_parse_copy_from(copy_from
, path
=None):
13 logger
.debug("Going to parse the copy_from setting.")
15 # Check if we already get a list:
16 if not isinstance(copy_from
, list):
17 copy_from
= copy_from
.split(" ")
20 for file in copy_from
:
22 # If file is empty we do not want to add it to the list
24 # If we get an absolut path we do nothing
25 # If not we add self.path to get an absolut path
26 if not os
.path
.isabs(file):
28 file = os
.path
.normpath(path
+ "/" + file)
30 file = os
.path
.abspath(file)
32 logger
.debug("Checking if '{}' is a valid file or dir".format(file))
33 # We need to check if file is a valid file or dir
34 if not (os
.path
.isdir(file) or os
.path
.isfile(file)):
35 raise SettingsException("'{}' is not a valid file nor a valid directory".format(file))
37 logger
.debug("'{}' will be copied into all images".format(file))