Commit d8c964d4 authored by Piergiorgio Pancino's avatar Piergiorgio Pancino Committed by Benoit Formet
Browse files

web/configuration: show a warning triangle when a file has problems

parent cc8b88f0
......@@ -51,6 +51,7 @@ class WebConfig(object):
"txt": dict(type="text", icon="file-o"),
"md": dict(type="markdown", icon="file-o"),
"yml": dict(type="yaml", icon="file-text-o"),
"yml-err": dict(type="yaml", icon="exclamation-triangle"),
"py": dict(type="python", icon="file-code-o"),
"html": dict(type="html", icon="file-code-o"),
"css": dict(type="css", icon="file-code-o"),
......@@ -257,7 +258,7 @@ class WebConfig(object):
item_path = os.path.join(path, name)
sub_items = {}
if data is None: # a file
ext_info = self.get_file_info(name)
ext_info = self.get_file_info(item_path)
meta = dict(
type="file", path=item_path, icon="fa fa-" + ext_info["icon"]
)
......@@ -272,6 +273,12 @@ class WebConfig(object):
ext = file_name.rpartition(os.path.extsep)[2]
if "." not in file_name:
ext = ""
# checking for invalid yaml files
cfg = self.get_config()
if file_name in cfg.invalid_yaml_files:
ext = "yml-err"
return self.EXT_MAP.setdefault(ext, dict(type=ext, icon="question"))
......
......@@ -509,6 +509,7 @@ class Config:
self._base_path = base_path
self._connection = connection or client.get_default_connection()
self.reload(timeout=timeout)
self.invalid_yaml_files = []
def close(self):
self._clear_instances()
......@@ -541,6 +542,7 @@ class Config:
self._file2node = {}
self._clear_instances()
self.invalid_yaml_files = []
path2file = client.get_config_db_files(
base_path=base_path, timeout=timeout, connection=self._connection
......@@ -570,6 +572,7 @@ class Config:
exp.note += "Hint: You can check your configuration with an on-line YAML validator like http://www.yamllint.com/ \n\n"
exp.problem_mark.name = path
if not raise_yaml_exc:
self.invalid_yaml_files.append(path)
continue
raise exp
# from ruamel.yaml.parser import ParserError
......@@ -620,6 +623,7 @@ class Config:
self._create_index(local_parent)
except ValueError:
if not raise_yaml_exc:
self.invalid_yaml_files.append(path)
continue
raise
else:
......@@ -635,6 +639,7 @@ class Config:
self._create_index(parents)
except ValueError:
if not raise_yaml_exc:
self.invalid_yaml_files.append(path)
continue
raise
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment