Skip to content

Commit

Permalink
New attempt at defusedxml
Browse files Browse the repository at this point in the history
  • Loading branch information
ewsterrenburg committed Aug 21, 2017
1 parent 97018c5 commit f156c89
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
13 changes: 10 additions & 3 deletions otrs/client.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""OTRS :: client."""
import abc
import codecs
import defusedxml.ElementTree as etree
from defusedxml import ElementTree as etree
try:
import http.client as httplib
import urllib.request as urllib2
Expand All @@ -11,16 +11,23 @@
from otrs.objects import extract_tagname
from otrs.objects import OTRSObject
from posixpath import join as urljoin
from otrs.objects import OTRSObject, extract_tagname
import sys
import xml.etree.ElementTree as etree
# defusedxml doesn't define these non-parsing related objects
from xml.etree.ElementTree import Element
from xml.etree.ElementTree import SubElement
from xml.etree.ElementTree import tostring

etree.Element = _ElementType = Element
etree.SubElement = SubElement
etree.tostring = tostring

# Fix Python 2.x.
try:
UNICODE_EXISTS = bool(type(unicode))
except NameError:
unicode = lambda s: str(s)


class OTRSError(Exception):
"""Base class for OTRS Errors."""

Expand Down
13 changes: 11 additions & 2 deletions otrs/objects.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
"""OTRS :: objects."""
from __future__ import unicode_literals
import base64
from defusedxml import ElementTree as etree
import os
import sys
import xml.etree.ElementTree as etree
# defusedxml doesn't define these non-parsing related objects
from xml.etree.ElementTree import Element
from xml.etree.ElementTree import SubElement
from xml.etree.ElementTree import tostring

# Fix Python 2.x.
etree.Element = _ElementType = Element
etree.SubElement = SubElement
etree.tostring = tostring

# Fix Python 3.x.
try:
UNICODE_EXISTS = bool(type(unicode))
except NameError:
unicode = lambda s: str(s)


class OTRSObject(object):
"""Represents an object for OTRS (mappable to an XML element)."""

Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setup(
name='python-otrs',
version='0.4.2',
version='0.4.3',
description='A programmatic interface to OTRS SOAP API.',
long_description=README,
author='Erwin Sterrenburg',
Expand All @@ -18,7 +18,9 @@
license='GPLv3',
zip_safe=False,
packages=find_packages(),
install_requires=['defusedxml'],
include_package_data=True,
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4',
keywords='otrs ticket support soap interface helpdesk',
classifiers=[
# How mature is this project? Common values are
Expand Down

0 comments on commit f156c89

Please sign in to comment.