es-ude / elastic-ai.creator

elastic ai.creator
MIT License
16 stars 2 forks source link

Simplify File Generation #316

Closed glencoe closed 1 year ago

glencoe commented 1 year ago

Current API for file generation (elasticai.creator.file_generation.on_disk_path.Path) was introduced such that objects receiving a Path could decide on their own, whether that is supposed to represent a file or a directory, while at the same time not being able to change or inspect the base name.

However this turns out to be rather complicated and not intuitive at all. Therefore I suggest we stick to a more traditional model for this and do something like

class Directory(Protocol):
    def make_subdirectory(self, name) -> "Directory": ...

    def make_file(self, name) -> "File": ...

class File(Protocol):
    def write(template: Template): ...

In case a hardware module consists of a single file I don't think it's too bad to just write it to something like build/my_single_file_module/my_single_file_module.vhd instead of build/my_single_file_module.vhd