Skip to content

Commit

Permalink
Implement ParsesReferences from latest bsb-core
Browse files Browse the repository at this point in the history
  • Loading branch information
drodarie committed May 21, 2024
1 parent 04ab917 commit 0260d72
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions bsb_yaml/parser.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import yaml
from bsb.config.parsers import ReferenceParser
from bsb.config.parsers import ConfigurationParser, ParsesReferences


class YAMLConfigurationParser(ReferenceParser):
class YAMLConfigurationParser(ParsesReferences, ConfigurationParser):
"""
Parser plugin class to parse YAML configuration files.
"""

data_description = "YAML"
data_extensions = ("yaml", "yml")

def from_str(self, filename):
return yaml.safe_load(filename)

def load_content(self, stream):
return yaml.safe_load(stream)
def parse(self, content, path=None):
content = yaml.safe_load(content)
meta = {"path": path}
return content, meta

def generate(self, tree, pretty=False):
return yaml.dump(tree, indent=None if not pretty else 2)
Expand Down

0 comments on commit 0260d72

Please sign in to comment.