Skip to content

improvements on dicttoxml#121

Merged
vinitkumar merged 10 commits into
vinitkumar:masterfrom
DirkRichter:master
Apr 20, 2022
Merged

improvements on dicttoxml#121
vinitkumar merged 10 commits into
vinitkumar:masterfrom
DirkRichter:master

Conversation

@DirkRichter

@DirkRichter DirkRichter commented Apr 19, 2022

Copy link
Copy Markdown
Contributor
  • support of namespaces
  • moving full object serialization into loglevel debug (reduce cpu + out of mem on large objects)
  • more control parameters on xml generation: allow custom xml attributes via attr + optionally omit encapsulating xml-nodes via Flat

Sorry, I was not able to extend your pull-request #120, thus i ceated a new one with fix for the failing test.

- support of namespaces
- moving full object serialization into loglevel debug (reduce cpu + out of mem on large objects)
- more control parameters on xml generation: allow custom xml attributes via @attr + optionally omit encapsulating xml-nodes via @Flat
@Flat

Flat commented Apr 19, 2022

Copy link
Copy Markdown

Can you please stop mentioning me? Thank you.

@vinitkumar

Copy link
Copy Markdown
Owner

Can you please stop mentioning me? Thank you.
@Flat I think it was a honest mistake from the contributor and not intentional. I have edited the description and it should be fine now. Apologies on the unintentional spam.

1 similar comment
@vinitkumar

Copy link
Copy Markdown
Owner

Can you please stop mentioning me? Thank you.
@Flat I think it was a honest mistake from the contributor and not intentional. I have edited the description and it should be fine now. Apologies on the unintentional spam.

@vinitkumar

Copy link
Copy Markdown
Owner

@DirkRichter Thanks for the timely fix. Since it's a big change, let me look into the code and understand before merging it.

@vinitkumar vinitkumar self-requested a review April 19, 2022 17:11
@vinitkumar vinitkumar changed the title improvments on dicttoxml improvements on dicttoxml Apr 19, 2022
@vinitkumar

Copy link
Copy Markdown
Owner

@DirkRichter Looked into the the code, it mostly looks good. Can we also adds tests supporting this new functionality. Something similar to how I test these? https://github.com/vinitkumar/json2xml/blob/master/tests/test_json2xml.py#L189 using an example json file: https://github.com/vinitkumar/json2xml/blob/master/examples/booleanjson2.json

And while we are at it, we should also update the readme about this newly added support for namespaces.

Please let me know what you think about these?

@DirkRichter

Copy link
Copy Markdown
Contributor Author

Yes, good idea: i will provide tests for checking future changes and to demonstrate usage. The namespace-support is just for xml (not sure how to handle in json).

@DirkRichter

Copy link
Copy Markdown
Contributor Author

Your new test shows problems with the old dicttoxml. The json sample

{
      "boolean_list": [true, false],
      "number_array": [1, 2, 3],
      "string_array": ["a", "b", "c"]
}

results in this xml:

<all>
        <item type="bool">true</item>
        <item type="bool">false</item>
        <item type="int">1</item>
        <item type="int">2</item>
        <item type="int">3</item>
        <string_array type="list">
                <item type="str">a</item>
                <item type="str">b</item>
                <item type="str">c</item>
        </string_array>
</all>

in my fixed dicttoxml version, corrently this xml is produced:

<all>
        <boolean_list type="list">
                <item type="bool">true</item>
                <item type="bool">false</item>
        </boolean_list>
        <number_array type="list">
                <item type="int">1</item>
                <item type="int">2</item>
                <item type="int">3</item>
        </number_array>
        <string_array type="list">
                <item type="str">a</item>
                <item type="str">b</item>
                <item type="str">c</item>
        </string_array>
</all>

Thus i will adapt the test. Or is there something, i'm not seeing?

@vinitkumar

Copy link
Copy Markdown
Owner

Your new test shows problems with the old dicttoxml. The json sample

{
      "boolean_list": [true, false],
      "number_array": [1, 2, 3],
      "string_array": ["a", "b", "c"]
}

results in this xml:

<all>
        <item type="bool">true</item>
        <item type="bool">false</item>
        <item type="int">1</item>
        <item type="int">2</item>
        <item type="int">3</item>
        <string_array type="list">
                <item type="str">a</item>
                <item type="str">b</item>
                <item type="str">c</item>
        </string_array>
</all>

in my fixed dicttoxml version, corrently this xml is produced:

<all>
        <boolean_list type="list">
                <item type="bool">true</item>
                <item type="bool">false</item>
        </boolean_list>
        <number_array type="list">
                <item type="int">1</item>
                <item type="int">2</item>
                <item type="int">3</item>
        </number_array>
        <string_array type="list">
                <item type="str">a</item>
                <item type="str">b</item>
                <item type="str">c</item>
        </string_array>
</all>

Thus i will adapt the test. Or is there something, i'm not seeing?

I think your changes are correct. Please adapt the test accordingly.

@DirkRichter

Copy link
Copy Markdown
Contributor Author
  • found and fixed some more issues (e.g. non-string dict-keys)
  • extend existing + added some more tests to demonstrate usage
  • you can merge again

@vinitkumar

Copy link
Copy Markdown
Owner

@DirkRichter There seems to be some conflicts as well. Can you please resolve them too?

# Conflicts:
#	tests/test_json2xml.py
@DirkRichter

DirkRichter commented Apr 20, 2022

Copy link
Copy Markdown
Contributor Author
  • again merged with master
  • conflicts solved
  • i think you can also drop dependency to regular xmltodict in .github\workflows\pythonpackage.yml
    pip install xmltodict==0.12.0 ... <= no i'm wrong. i mix-up with dicttoxml, sorry

@vinitkumar

Copy link
Copy Markdown
Owner

i think you can also drop dependency to regular xmltodict in .github\workflows\pythonpackage.yml
pip install xmltodict==0.12.0

@DirkRichter Please feel free to make the changes.

@vinitkumar

Copy link
Copy Markdown
Owner

@DirkRichter Also, I added flake8 and isort in the mix, so if there are lint failures, CI will fail and you will need to clean up the code.

@codecov-commenter

codecov-commenter commented Apr 20, 2022

Copy link
Copy Markdown

Codecov Report

Merging #121 (fa15a8e) into master (fe72f27) will increase coverage by 2.83%.
The diff coverage is 89.79%.

@@            Coverage Diff             @@
##           master     #121      +/-   ##
==========================================
+ Coverage   86.27%   89.11%   +2.83%     
==========================================
  Files           5        5              
  Lines         379      441      +62     
==========================================
+ Hits          327      393      +66     
+ Misses         52       48       -4     
Impacted Files Coverage Δ
json2xml/dicttoxml.py 81.98% <84.61%> (+5.01%) ⬆️
tests/test_json2xml.py 99.33% <100.00%> (+0.17%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fe72f27...fa15a8e. Read the comment docs.

@vinitkumar vinitkumar merged commit d4b72cc into vinitkumar:master Apr 20, 2022
@vinitkumar

Copy link
Copy Markdown
Owner

@DirkRichter Thanks a tonne for all your hardwork. I will merge the PR now and then I want the code to brew for a while, and then make a major release. I might also do some optimisation on top of it before making the release.

@vinitkumar

vinitkumar commented Apr 21, 2022

Copy link
Copy Markdown
Owner

@DirkRichter I think some code went missing during merge/fixing conflicts.

<all>
        <boolean_list type="list">
                <item type="bool">true</item>
                <item type="bool">false</item>
        </boolean_list>
        <number_array type="list">
                <item type="int">1</item>
                <item type="int">2</item>
                <item type="int">3</item>
        </number_array>
        <string_array type="list">
                <item type="str">a</item>
                <item type="str">b</item>
                <item type="str">c</item>
        </string_array>
</all>

This doesn't seems to work with that I merged last evening.

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

Successfully merging this pull request may close these issues.

4 participants