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

0.5.2 Feature Request: Reader parse-only mode. #103

Open
qg020 opened this issue Feb 14, 2024 · 6 comments
Open

0.5.2 Feature Request: Reader parse-only mode. #103

qg020 opened this issue Feb 14, 2024 · 6 comments

Comments

@qg020
Copy link

qg020 commented Feb 14, 2024

I am reading ARXML we have generated and it is not to the Reader's liking. I have iterated through fixing each raised exception. A nice feature would be a 'parse-only' flag that would return a list of all lines in an ARXML file needing attention and why it is a problem.

@cogu
Copy link
Owner

cogu commented Feb 20, 2024

Does the parsing stop because an exception is raised by the parser? In that case I can add an option to continue parsing and not stop by raising an error.

Also, have you verified your ARXML file against the schema file before trying to parse?
I always use xmllint tool to verify any XML file first. I always check against schema versions 48, 49, 50 and 51. If your ARXML uses any other version I cannot give any support.

Finally, the new code base is still in early development. I haven't tried it myself yet to parse any XML generated by other tool or script. I will start testing it later, somewhere after v0.5.4.

@qg020
Copy link
Author

qg020 commented Feb 20, 2024

Hi cogu, thanks for the response. ARXML input files mention r4.0 AUTOSAR_4-2-2. The problem is definitely in our ARMXL which have duplicate entries. All errors reported by the Reader indicate that. Which is great. Just a convenience thing if you could ask to see all the parsing problems at once.

Low hanging fruit for when you have time (haha). Thanks!

@cogu
Copy link
Owner

cogu commented Mar 29, 2024

When I have time I plan to add a boolean flag to the reader class named something like "stop_on_error" which defaults to True.
Manually setting it to False should get the effect you want.

But before I can add that I have to refactor all the places in the Reader code that raises an exception to only print a warning based on this flag. It's gonna take some time to do.

@rcd09
Copy link

rcd09 commented Mar 30, 2024 via email

@cogu
Copy link
Owner

cogu commented Mar 31, 2024

@rcd09, Actually when I think about it I would prefer to keep most of the exceptions and instead catch them in a try-except block in the method _read_package_elements.

  • If the element is too broken to parse then we just skip it and move on to the next element
  • If the element is a duplicate, as seems to be the case for @qg020 then the line package.append(element) inside _read_package_elements will raise an exception instead, which we can catch in the same place.

I can make the change to the _read_package_elements. It should be a quick fix.

@cogu
Copy link
Owner

cogu commented Mar 31, 2024

@qg020, @rcd09, I've made a first attempt of the change on latest master. There is still a lot of improvements that can be made but it should be good enough for now.

I decided to let stop_on_error be False as default. Now you have to explicitly set it to True to stop reading the XML.

See print_errors.py example with an invalid ARXML containing duplicates.

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