Skip to content

Commit 1d7df1a

Browse files
author
Sam Stelle
committed
Removed unecessary handling. Changed test_collection.py
1 parent 593f122 commit 1d7df1a

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

splunklib/client.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,7 +1540,7 @@ def delete(self, name, **params):
15401540
raise KeyError("No such entity %s" % name)
15411541
else:
15421542
raise
1543-
return
1543+
return self
15441544

15451545
def get(self, name="", owner=None, app=None, sharing=None, **query):
15461546
"""Performs a GET request to the server on the collection.
@@ -2018,13 +2018,6 @@ def __getitem__(self, key):
20182018
if isinstance(key, tuple) and len(key) == 2:
20192019
# Fetch a single kind
20202020
key, kind = key
2021-
if kind == "script":
2022-
keylist = key.split('/')
2023-
applist = [app.name for app in self.service.apps]
2024-
for i in range(len(keylist)):
2025-
if keylist[i] == "apps" and keylist[i+1] in applist:
2026-
newkey = [keylist[x] for x in range(i + 2, len(keylist))]
2027-
key = "./" + ('/').join(newkey)
20282021
key = UrlEncoded(key, encode_slash=True)
20292022
try:
20302023
response = self.get(self.kindpath(kind) + "/" + key)
@@ -2044,12 +2037,6 @@ def __getitem__(self, key):
20442037
# Iterate over all the kinds looking for matches.
20452038
kind = None
20462039
candidate = None
2047-
keylist = key.split('/')
2048-
applist = [app.name for app in self.service.apps]
2049-
for i in range(len(keylist)):
2050-
if keylist[i] == "apps" and keylist[i+1] in applist:
2051-
newkey = [keylist[x] for x in range(i + 2, len(keylist))]
2052-
key = "./" + ('/').join(newkey)
20532040
key = UrlEncoded(key, encode_slash=True)
20542041
for kind in self.kinds:
20552042
try:
@@ -2226,7 +2213,7 @@ def itemmeta(self, kind):
22262213
def _get_kind_list(self, subpath=None):
22272214
if subpath is None:
22282215
subpath = []
2229-
2216+
22302217
kinds = []
22312218
response = self.get('/'.join(subpath))
22322219
content = _load_atom_entries(response)

tests/test_collection.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,9 @@ def test_collection_search_get(self):
250250
self.assertEqual(200, self.service.saved_searches.get(search.name).status)
251251

252252
def test_collection_inputs_getitem(self):
253-
for inp in self.service.inputs:
253+
valid_kinds = self.service.inputs._get_kind_list()
254+
valid_kinds.remove("script")
255+
for inp in self.service.inputs.list(*valid_kinds):
254256
self.assertTrue(self.service.inputs[inp.name])
255257

256258

0 commit comments

Comments
 (0)