Skip to content
Snippets Groups Projects
Commit 5c335d2f authored by Alexander Schlemmer's avatar Alexander Schlemmer
Browse files

MAINT: revert addition of yaml converter which is part of f-yaml-converter

parent f17befaa
No related branches found
No related tags found
2 merge requests!53Release 0.1,!42F doc
Pipeline #28752 passed
...@@ -552,51 +552,6 @@ class FileConverter(Converter): ...@@ -552,51 +552,6 @@ class FileConverter(Converter):
return [] return []
class YAMLFileConverter(DictConverter):
"""
Converter for yaml files very similar to the json converter.
"""
def typecheck(self, element: StructureElement):
return isinstance(element, File)
def match(self, element: StructureElement):
if not self.typecheck(element):
raise RuntimeError("Element must be a file")
m = re.match(self.definition["match"], element.name)
if m is None:
return None
return m.groupdict()
def create_children(self, generalStore: GeneralStore, element: StructureElement):
if not self.typecheck(element):
raise RuntimeError("A YAML file is needed to create children")
with open(element.path, 'r') as yaml_file:
yaml_data = yaml.safe_load(yaml_file)
if not isinstance(yaml_data, dict):
breakpoint()
raise NotImplementedError("YAML file must contain a dict")
raise NotImplementedError()
# if "validate" in self.definition and self.definition["validate"]:
# if isinstance(self.definition["validate"], dict):
# schema = self.definition["validate"]
# elif isinstance(self.definition["validate"], str):
# with open(self.definition["validate"], 'r') as json_file:
# schema = json.load(json_file)
# else:
# raise ValueError("The value of 'validate' has to be a string describing the path "
# "to the json schema file (relative to the cfood yml) "
# "or a dict containing the schema.")
# # Validate the json content
# try:
# validate(instance=json_data, schema=schema)
# except ValidationError as err:
# raise ConverterValidationError(
# f"Couldn't validate {json_data}:\n{err.message}")
return self._create_children_from_dict(yaml_data)
class JSONFileConverter(DictConverter): class JSONFileConverter(DictConverter):
def typecheck(self, element: StructureElement): def typecheck(self, element: StructureElement):
return isinstance(element, File) return isinstance(element, File)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment