Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: django CMS linters.yml

on: [push, pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
flake8:
name: flake8
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.9
cache: 'pip'
- run: pip install --upgrade flake8
- name: flake8
uses: liskin/gh-problem-matcher-wrap@v1
with:
linters: flake8
run: flake8

isort:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.9
cache: 'pip'
- run: python -m pip install isort
- name: isort
uses: liskin/gh-problem-matcher-wrap@v1
with:
linters: isort
run: isort --check --diff json2xml
8 changes: 6 additions & 2 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ jobs:
pip install flake8
pip install xmltodict==0.12.0
pip install pytest==7.0.1
pip install coverage==6.3.2
pip install py==1.11.0
# stop the build if there are Python syntax errors or undefined names
flake8 json2xml/ --exit-zero
- name: Test with pytest
- name: Unit tests
run: |
pytest
coverage run -m pytest
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ json2xml
.. image:: https://readthedocs.org/projects/json2xml/badge/?version=latest
:target: https://json2xml.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
.. image:: https://coveralls.io/repos/github/vinitkumar/json2xml/badge.svg?branch=master
:target: https://coveralls.io/github/vinitkumar/json2xml?branch=master
.. image:: https://codecov.io/gh/vinitkumar/json2xml/branch/master/graph/badge.svg?token=Yt2h55eTL2
:target: https://codecov.io/gh/vinitkumar/json2xml


Simple Python Library to convert JSON to XML
Expand Down
7 changes: 2 additions & 5 deletions json2xml/dicttoxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import logging
import numbers
from random import randint
from defusedxml.minidom import parseString
from typing import Any, Dict

from typing import Dict, Any
from defusedxml.minidom import parseString

LOG = logging.getLogger("dicttoxml")

Expand Down Expand Up @@ -137,9 +137,7 @@ def convert(obj, ids, attr_type, item_func, cdata, item_wrap, parent="root"):

LOG.info(f'Inside convert(). obj type is: "{type(obj).__name__}", obj="{str(obj)}"')


item_name = item_func(parent)

# since bool is also a subtype of number.Number and int, the check for bool
# never comes and hence we get wrong value for the xml type bool
# here, we just change order and check for bool first, because no other
Expand Down Expand Up @@ -303,7 +301,6 @@ def convert_list(items, ids, parent, attr_type, item_func, cdata, item_wrap):
)
)


elif isinstance(item, dict):
item_dict_str = convert_dict(
item,
Expand Down
5 changes: 4 additions & 1 deletion json2xml/json2xml.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from typing import Optional, Any
from typing import Any, Optional

from defusedxml.minidom import parseString
from pyexpat import ExpatError

from json2xml import dicttoxml

from .utils import InvalidDataError


Expand Down
1 change: 1 addition & 0 deletions json2xml/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Utils methods to convert XML data to dict from various sources"""
import json
from typing import Dict, Optional

import requests


Expand Down
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ no_implicit_optional = true
warn_redundant_casts = true
warn_unused_ignores = true
ignore_missing_imports = true


[coverage:run]
relative_files = True
1 change: 0 additions & 1 deletion tests/test_json2xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ def test_read_boolean_data_from_json(self):
assert dict_from_xml["all"]["boolean"]["#text"] != 'True'
assert dict_from_xml["all"]["boolean"]["#text"] == 'true'


def test_read_boolean_data_from_json2(self):
"""Test correct return for boolean types."""
data = readfromjson("examples/booleanjson2.json")
Expand Down
Loading