Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mergeparameters AttributeError: 'dict' object has no attribute 'move_to_end' #53

Closed
corrpel opened this issue Dec 27, 2022 · 5 comments
Closed

Comments

@corrpel
Copy link

corrpel commented Dec 27, 2022

Hello,
I am trying to use the merge tool for metadata, but i receive the following errors:

'''
pi@raspberrypi:~/phat $ mergeparameters dsc_phat.xml dsc_phat.params
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/hifiberrydsp/parser/xmlprofile.py", line 253, in update_metadata
beometa = self.doc["ROM"]["beometa"]
KeyError: 'beometa'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/bin/mergeparameters", line 28, in
merge_params_main()
File "/usr/local/lib/python3.9/dist-packages/hifiberrydsp/parser/sigmaparams.py", line 236, in merge_params_main
params = pf.merge_params_into_xml(xmlfile)
File "/usr/local/lib/python3.9/dist-packages/hifiberrydsp/parser/sigmaparams.py", line 190, in merge_params_into_xml
xml.update_metadata(param_list)
File "/usr/local/lib/python3.9/dist-packages/hifiberrydsp/parser/xmlprofile.py", line 257, in update_metadata
self.doc["ROM"].move_to_end('beometa', last=False)
AttributeError: 'dict' object has no attribute 'move_to_end'
'''

Running python3.9 and and latest dsptoolkit from pip

@KruzFX
Copy link

KruzFX commented Jan 11, 2023

I just experienced the same problem. Two years ago when I last used the tool there was no such a problem. Maybe there is a problem with new python versions?

@ssalonen
Copy link
Contributor

ssalonen commented Feb 26, 2023

Just hit this issue myself, it is due to backwards compatible change in xmltodict v0.13 (xmltodict is dsptoolkit dependency)

Fix is simple: xmltodict.parse() needs additional parameter dict_constructor=OrderedDict. In parser/xmlprofile.py:

self.doc = xmltodict.parse(fd.read(), dict_constructor=OrderedDict)

@KruzFX
Copy link

KruzFX commented Mar 1, 2023

Thanks for the reply. But where is the file when installed on my Raspberry Pi?

@ssalonen
Copy link
Contributor

ssalonen commented Mar 2, 2023

You can see it in the error message

Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/hifiberrydsp/parser/xmlprofile.py"

ssalonen added a commit to ssalonen/hifiberry-dsp that referenced this issue Mar 2, 2023
xmltodict v0.13 started using dict (instead of previous default
OrderedDict) when parsing xml with python < 3.7. See
martinblech/xmltodict@231b4d4

This restores the previous behaviour, using OrderedDict, making the
behaviour compatible with dsptoolkit. The change should be backwards
compatible with older versions of xmltodict, as dict_constructor
parameter has been there for quite some time.

Signed-off-by: Sami Salonen <[email protected]>
@ssalonen
Copy link
Contributor

ssalonen commented Mar 2, 2023

PR submitted in #54

hifiberry added a commit that referenced this issue Mar 2, 2023
Fix for xmltodict v0.13. Fixes #53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants