Re: [PATCH v2 3/5] dts: add parsing utility module

2024-06-05 Thread Luca Vizzarro
On 05/06/2024 13:19, Juraj Linkeš wrote: +    return cls.compose(partial(int, base=int_base), cls.find(pattern)) + +    """ END PARSER FUNCTIONS """ + +    @classmethod +    def parse(cls, text: str) -> Self: Would converting this into __init__(self, text: str) work

Re: [PATCH v2 3/5] dts: add parsing utility module

2024-06-05 Thread Juraj Linkeš
+ +    """ BEGIN PARSER FUNCTIONS """ + +    @staticmethod +    def compose(f: Callable, parser_fn: ParserFn) -> ParserFn: +    """Makes a composite parser function. + +    The parser function is run and if a non-None value was returned, f is called with it.

Re: [PATCH v2 3/5] dts: add parsing utility module

2024-06-05 Thread Luca Vizzarro
On 04/06/2024 16:13, Juraj Linkeš wrote: I'd like to see a high level explanation of what the key pieces of the parsing are and how they're tied to the implementation: 1. The text we're about to parse, passed to the instance of a subclass 2. What we're parsing, the fields of the subclass 3. How

Re: [PATCH v2 3/5] dts: add parsing utility module

2024-06-04 Thread Juraj Linkeš
There are mostly documentation and basically inconsequential minor comments. On 9. 5. 2024 13:26, Luca Vizzarro wrote: Adds parsing text into a custom dataclass. It provides a new `TextParser` dataclass to be inherited. This implements the `parse` method, which combined with the parser functions

Re: [PATCH v2 3/5] dts: add parsing utility module

2024-05-31 Thread Jeremy Spewock
On Thu, May 9, 2024 at 7:26 AM Luca Vizzarro wrote: > > Adds parsing text into a custom dataclass. It provides a new > `TextParser` dataclass to be inherited. This implements the `parse` > method, which combined with the parser functions, it can automatically > parse the value for each field. > >

[PATCH v2 3/5] dts: add parsing utility module

2024-05-09 Thread Luca Vizzarro
Adds parsing text into a custom dataclass. It provides a new `TextParser` dataclass to be inherited. This implements the `parse` method, which combined with the parser functions, it can automatically parse the value for each field. This new utility will facilitate and simplify the parsing of compl