Skip to content

Commit c9ff403

Browse files
authored
Merge pull request #29 from orf/patch-1
Remove the dependency on lxml
2 parents c7db8ac + 04dbb40 commit c9ff403

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
requests==2.20.1
22
defusedxml==0.5.0
3-
lxml==4.2.3
43
python-dateutil==2.7.3

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
install_requires=[
4141
'requests==2.20.1',
4242
'defusedxml==0.5.0',
43-
'lxml==4.2.3',
4443
'python-dateutil==2.7.3'
4544
],
4645
test_suite='tests',

src/onelogin/api/client.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import datetime
1313
from dateutil import tz
1414
import requests
15-
from defusedxml.lxml import fromstring
15+
from defusedxml.ElementTree import fromstring
1616

1717
from onelogin.api.util.urlbuilder import UrlBuilder
1818
from onelogin.api.util.constants import Constants
@@ -207,14 +207,15 @@ def extract_status_code_from_response(self, response):
207207

208208
def retrieve_apps_from_xml(self, xml_content):
209209
root = fromstring(xml_content)
210-
node_list = root.xpath("/apps/app")
211-
attributes = ["id", "icon", "name", "provisioned", "extension_required", "personal", "login_id"]
210+
node_list = root.findall("./app")
211+
attributes = {"id", "icon", "name", "provisioned", "extension_required", "personal", "login_id"}
212212
apps = []
213213
for node in node_list:
214-
app_data = {}
215-
for children in node.getchildren():
216-
if children.tag in attributes:
217-
app_data[children.tag] = children.text
214+
app_data = {
215+
child.tag: child.text
216+
for child in node
217+
if child.tag in attributes
218+
}
218219
apps.append(EmbedApp(app_data))
219220
return apps
220221

0 commit comments

Comments
 (0)