mercedes-benz / odxtools

odxtools is a collection of utilities to interact with the diagnostic functionality of automotive electronic control units using python
MIT License
171 stars 70 forks source link

use a context for the `_resolve_*()` methods #290

Open andlaus opened 5 months ago

andlaus commented 5 months ago

currently most methods for resolving references (resolve_odxlinks() and _resolve_snrefs()) take the odxlinks database or the diagnostic layer as their argument. Unfortunately, this is not always sufficient because some of these methods require additional parameters (example). The approach currently taken is to introduce new _resolve_*() methods for affected classes which must be called instead of the generic versions. Alternatively it would be possible to pass an object describing the full calling context and let the called method determine the required information. E.g.

def _resolve_snrefs(self, context: CallingContext) -> None:
    params = context.parameters
    ...

Note that this would require a major refactoring because all classes would be affected and it might even make the code worse (in the sense of "more complicated")