Skip to content

Commit

Permalink
Merge branch 'release/2.5' into hotfix/2.5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkLark86 committed Feb 17, 2023
2 parents 42d16cf + 9ba2b70 commit d0862b5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- run: pip install black
- run: pip install black~=22.0
- run: black --check .

flake8:
Expand Down
10 changes: 10 additions & 0 deletions superdesk/io/feeding_services/ap_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

logger = logging.getLogger(__name__)

nitf_namespace = {"nitf": "http://iptc.org/std/NITF/2006-10-18/"}


class APMediaFeedingService(HTTPFeedingServiceBase):
"""
Expand Down Expand Up @@ -181,6 +183,14 @@ def _update(self, provider, update):
logger.info("Get AP nitf : {}".format(nitf_ref))
r = self.api_get(nitf_ref, provider)
root_elt = etree.fromstring(r.content)

# If the default namespace definition is the nitf namespace then remove it
if root_elt.nsmap and root_elt.nsmap.get(None) == nitf_namespace["nitf"]:
for elem in root_elt.getiterator():
if elem.tag:
elem.tag = elem.tag.replace("{" + nitf_namespace["nitf"] + "}", "")
etree.cleanup_namespaces(root_elt)

nitf_item = nitf.NITFFeedParser().parse(root_elt)
complete_item["nitf"] = nitf_item
else:
Expand Down
3 changes: 2 additions & 1 deletion tests/io/fixtures/ap_media_text_nitf.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<nitf version="-//IPTC//DTD NITF 3.4//EN" change.date="October 18, 2006" change.time="19:30">
<nitf xmlns="http://iptc.org/std/NITF/2006-10-18/" version="-//IPTC//DTD NITF 3.4//EN" change.date="October 18, 2006"
change.time="19:30">
<head>
<docdata>
<doc-id regsrc="AP"/>
Expand Down

0 comments on commit d0862b5

Please sign in to comment.