mercedes-benz / odxtools

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

Hotfix for ComparamInstance #247

Closed kayoub5 closed 11 months ago

kayoub5 commented 11 months ago

short name is only available after resolving references, change creation code to postpone Named List creation Stack trace

.nox/tests/lib/python3.8/site-packages/odxtools/load_pdx_file.py:8: in load_pdx_file
    return Database(pdx_zip=ZipFile(pdx_file))
.nox/tests/lib/python3.8/site-packages/odxtools/database.py:72: in __init__
    dlcs.append(DiagLayerContainer.from_et(dlc, []))
.nox/tests/lib/python3.8/site-packages/odxtools/diaglayercontainer.py:60: in from_et
    functional_groups = NamedItemList([
.nox/tests/lib/python3.8/site-packages/odxtools/diaglayercontainer.py:61: in <listcomp>
    DiagLayer.from_et(dl_element, doc_frags)
.nox/tests/lib/python3.8/site-packages/odxtools/diaglayer.py:59: in from_et
    diag_layer_raw = DiagLayerRaw.from_et(et_element, doc_frags)
.nox/tests/lib/python3.8/site-packages/odxtools/diaglayerraw.py:113: in from_et
    dc = DiagService.from_et(dc_proxy_elem, doc_frags)
.nox/tests/lib/python3.8/site-packages/odxtools/diagservice.py:59: in from_et
    comparam_refs = NamedItemList([
.nox/tests/lib/python3.8/site-packages/odxtools/nameditemlist.py:43: in __init__
    self.append(item)
.nox/tests/lib/python3.8/site-packages/odxtools/nameditemlist.py:56: in append
    item_name = self._get_item_key(item)
.nox/tests/lib/python3.8/site-packages/odxtools/nameditemlist.py:192: in _get_item_key
    return short_name_as_key(obj)
.nox/tests/lib/python3.8/site-packages/odxtools/nameditemlist.py:176: in short_name_as_key
    sn = obj.short_name
.nox/tests/lib/python3.8/site-packages/odxtools/comparaminstance.py:141: in short_name
    if self.spec:
andlaus commented 11 months ago

Thanks for the fix. I suppose _comparams can possibly also be created at the end od .resolve_odxlinks but I'm not sure about that and it shouldn't delay the merge of the PR anyway...