Skip to content

Commit 4d59e60

Browse files
author
Shakeel Mohamed
committed
modify atom parsing to retain the type property if it isn't "text/xml", should address #92
1 parent c7a1565 commit 4d59e60

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

splunklib/client.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,16 @@ def _parse_atom_entry(entry):
237237

238238
# Filter some of the noise out of the content record
239239
content = record((k, v) for k, v in content.iteritems()
240-
if k not in ['eai:acl', 'eai:attributes', 'type'])
240+
if k not in ['eai:acl', 'eai:attributes'])
241+
242+
if type(content['type']) is type([]):
243+
content['type'] = [t for t in content['type'] if t != 'text/xml']
244+
if len(content['type']) == 0: # Unset type if it was only 'text/xml'
245+
content.pop('type', None)
246+
if len(content['type']) == 1: # Flatten 1 element list
247+
content['type'] = content['type'][0]
248+
else:
249+
content.pop('type', None)
241250

242251
return record({
243252
'title': title,

tests/test_service.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,20 @@ def test_restart(self):
103103
self.service.restart(timeout=120)
104104
service.login() # Make sure we are awake
105105

106+
def test_read_outputs_with_type(self):
107+
name = testlib.tmpname()
108+
service = client.connect(**self.opts.kwargs)
109+
service.post('data/outputs/tcp/syslog', name=name, type='tcp')
110+
entity = client.Entity(service, 'data/outputs/tcp/syslog/' + name)
111+
self.assertTrue('tcp', entity.content.type)
112+
113+
if service.restart_required:
114+
self.restartSplunk()
115+
service = client.connect(**self.opts.kwargs)
116+
client.Entity(service, 'data/outputs/tcp/syslog/' + name).delete()
117+
if service.restart_required:
118+
self.restartSplunk()
119+
106120
def test_splunk_version(self):
107121
service = client.connect(**self.opts.kwargs)
108122
v = service.splunk_version

0 commit comments

Comments
 (0)