Skip to content

Commit 1a4fa9b

Browse files
author
Frederick Ross
committed
Resolved review comments.
1 parent 1215d2a commit 1a4fa9b

File tree

1 file changed

+10
-30
lines changed

1 file changed

+10
-30
lines changed

splunklib/client.py

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2424,12 +2424,8 @@ def events(self, **kwargs):
24242424
24252425
:return: The ``InputStream`` IO handle to this job's events.
24262426
"""
2427-
if 'segmentation' not in kwargs:
2428-
segmentation = 'none'
2429-
else:
2430-
segmentation = kwargs.pop('segmentation')
2431-
return self.get("events", segmentation=segmentation,
2432-
**kwargs).body
2427+
kwargs['segmentation'] = kwargs.get('segmentation', 'none')
2428+
return self.get("events", **kwargs).body
24332429

24342430
def finalize(self):
24352431
"""Stops the job and provides intermediate results for retrieval.
@@ -2514,12 +2510,8 @@ def results(self, **query_params):
25142510
25152511
:return: The ``InputStream`` IO handle to this job's results.
25162512
"""
2517-
if 'segmentation' not in query_params:
2518-
segmentation = 'none'
2519-
else:
2520-
segmentation = query_params.pop('segmentation')
2521-
return self.get("results", segmentation=segmentation,
2522-
**query_params).body
2513+
query_params['segmentation'] = query_params.get('segmentation', 'none')
2514+
return self.get("results", **query_params).body
25232515

25242516
def preview(self, **query_params):
25252517
"""Returns a streaming handle to this job's preview search results.
@@ -2561,12 +2553,8 @@ def preview(self, **query_params):
25612553
25622554
:return: The ``InputStream`` IO handle to this job's preview results.
25632555
"""
2564-
if 'segmentation' not in query_params:
2565-
segmentation = 'none'
2566-
else:
2567-
segmentation = query_params.pop('segmentation')
2568-
return self.get("results_preview", segmentation=segmentation,
2569-
**query_params).body
2556+
query_params['segmentation'] = query_params.get('segmentation', 'none')
2557+
return self.get("results_preview", **query_params).body
25702558

25712559
def searchlog(self, **kwargs):
25722560
"""Returns a streaming handle to this job's search log.
@@ -2733,13 +2721,9 @@ def export(self, query, **params):
27332721
"""
27342722
if "exec_mode" in params:
27352723
raise TypeError("Cannot specify an exec_mode to export.")
2736-
if 'segmentation' not in params:
2737-
segmentation = 'none'
2738-
else:
2739-
segmentation = params.pop('segmentation')
2740-
return self.post(path_segment="export",
2724+
params['segmentation'] = params.get('segmentation', 'none')
2725+
return self.post(path_segment="export",
27412726
search=query,
2742-
segmentation=segmentation,
27432727
**params).body
27442728

27452729
def itemmeta(self):
@@ -2800,13 +2784,9 @@ def oneshot(self, query, **params):
28002784
"""
28012785
if "exec_mode" in params:
28022786
raise TypeError("Cannot specify an exec_mode to oneshot.")
2803-
if 'segmentation' not in params:
2804-
segmentation = 'none'
2805-
else:
2806-
segmentation = params.pop('segmentation')
2807-
return self.post(search=query,
2787+
params['segmentation'] = params.get('segmentation', 'none')
2788+
return self.post(search=query,
28082789
exec_mode="oneshot",
2809-
segmentation=segmentation,
28102790
**params).body
28112791

28122792

0 commit comments

Comments
 (0)