dbbs-lab / bsb-core

The Brain Scaffold Builder
https://bsb.readthedocs.io
GNU General Public License v3.0
22 stars 16 forks source link

Feature/recursive parsing #847

Closed drodarie closed 6 months ago

drodarie commented 6 months ago

Describe the work done

Add recursive configuration file parsing. This will also allow Configuration parsing though different type of parsers. Merge ConfigurationParser and ReferenceConfigurationParser.

NOTE: Configuration file reference path are currently relative to the files instead of the script, but this can be changed

List which issues this resolves:

closes #845

Tasks

Helveg commented 6 months ago

ConfigurationParser needs to keep this abstract interface:

class ConfigurationParser:
  def parse(): ...
  def generate(): ...

I propose to instead create functional mixin classes that postprocess the return value:

class ParsesReferences:
  def __init_subclass__(cls):
    wrap(cls.parse, cls.parse_references)
class ParsesImports:
  def __init_subclass__(cls):
    wrap(cls.parse, cls.parse_imports)

So developers can:

class MyParser(ParsesRecursively, ConfigurationParser):
  def parse():
    return { "parsed": "value" }

and if the return value contains anything recursive it would be parsed.