Skip to content

Commit 8cc4c21

Browse files
committed
updated comments examples
1 parent 917cf04 commit 8cc4c21

File tree

5 files changed

+31
-31
lines changed

5 files changed

+31
-31
lines changed

splunklib/binding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def _authentication(request_fun):
271271
def f():
272272
c.get("/services")
273273
return 42
274-
print _authentication(f)
274+
print(_authentication(f))
275275
"""
276276

277277
@wraps(request_fun)

splunklib/client.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
are subclasses of :class:`Entity`. An ``Entity`` object has fields for its
5555
attributes, and methods that are specific to each kind of entity. For example::
5656
57-
print my_app['author'] # Or: print my_app.author
57+
print(my_app['author']) # Or: print(my_app.author)
5858
my_app.package() # Creates a compressed package of this application
5959
"""
6060

@@ -1393,7 +1393,7 @@ def __iter__(self, **kwargs):
13931393
c = client.connect(...)
13941394
saved_searches = c.saved_searches
13951395
for entity in saved_searches:
1396-
print "Saved search named %s" % entity.name
1396+
print(f"Saved search named {entity.name}")
13971397
"""
13981398

13991399
for item in self.iter(**kwargs):
@@ -2880,10 +2880,10 @@ def results(self, **query_params):
28802880
for result in rr:
28812881
if isinstance(result, results.Message):
28822882
# Diagnostic messages may be returned in the results
2883-
print '%s: %s' % (result.type, result.message)
2883+
print(f'{result.type}: {result.message}')
28842884
elif isinstance(result, dict):
28852885
# Normal events are returned as dicts
2886-
print result
2886+
print(result)
28872887
assert rr.is_preview == False
28882888
28892889
Results are not available until the job has finished. If called on
@@ -2924,14 +2924,14 @@ def preview(self, **query_params):
29242924
for result in rr:
29252925
if isinstance(result, results.Message):
29262926
# Diagnostic messages may be returned in the results
2927-
print '%s: %s' % (result.type, result.message)
2927+
print(f'{result.type}: {result.message}')
29282928
elif isinstance(result, dict):
29292929
# Normal events are returned as dicts
2930-
print result
2930+
print(result)
29312931
if rr.is_preview:
2932-
print "Preview of a running search job."
2932+
print("Preview of a running search job.")
29332933
else:
2934-
print "Job is finished. Results are final."
2934+
print("Job is finished. Results are final.")
29352935
29362936
This method makes one roundtrip to the server, plus at most
29372937
two more if
@@ -3097,10 +3097,10 @@ def export(self, query, **params):
30973097
for result in rr:
30983098
if isinstance(result, results.Message):
30993099
# Diagnostic messages may be returned in the results
3100-
print '%s: %s' % (result.type, result.message)
3100+
print(f'{result.type}: {result.message}')
31013101
elif isinstance(result, dict):
31023102
# Normal events are returned as dicts
3103-
print result
3103+
print(result)
31043104
assert rr.is_preview == False
31053105
31063106
Running an export search is more efficient as it streams the results
@@ -3153,10 +3153,10 @@ def oneshot(self, query, **params):
31533153
for result in rr:
31543154
if isinstance(result, results.Message):
31553155
# Diagnostic messages may be returned in the results
3156-
print '%s: %s' % (result.type, result.message)
3156+
print(f'{result.type}: {result.message}')
31573157
elif isinstance(result, dict):
31583158
# Normal events are returned as dicts
3159-
print result
3159+
print(result)
31603160
assert rr.is_preview == False
31613161
31623162
The ``oneshot`` method makes a single roundtrip to the server (as opposed

splunklib/results.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
reader = ResultsReader(result_stream)
3030
for item in reader:
3131
print(item)
32-
print "Results are a preview: %s" % reader.is_preview
32+
print(f"Results are a preview: {reader.is_preview}")
3333
"""
3434

3535
from io import BufferedReader, BytesIO
@@ -174,10 +174,10 @@ class ResultsReader:
174174
reader = results.ResultsReader(response)
175175
for result in reader:
176176
if isinstance(result, dict):
177-
print "Result: %s" % result
177+
print(f"Result: {result}")
178178
elif isinstance(result, results.Message):
179-
print "Message: %s" % result
180-
print "is_preview = %s " % reader.is_preview
179+
print(f"Message: {result}")
180+
print(f"is_preview = {reader.is_preview}")
181181
"""
182182

183183
# Be sure to update the docstrings of client.Jobs.oneshot,
@@ -292,10 +292,10 @@ class JSONResultsReader:
292292
reader = results.JSONResultsReader(response)
293293
for result in reader:
294294
if isinstance(result, dict):
295-
print "Result: %s" % result
295+
print(f"Result: {result}")
296296
elif isinstance(result, results.Message):
297-
print "Message: %s" % result
298-
print "is_preview = %s " % reader.is_preview
297+
print(f"Message: {result}")
298+
print(f"is_preview = {reader.is_preview}")
299299
"""
300300

301301
# Be sure to update the docstrings of client.Jobs.oneshot,

tests/test_job.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ def test_export_docstring_sample(self):
8585
for result in rr:
8686
if isinstance(result, results.Message):
8787
# Diagnostic messages may be returned in the results
88-
pass #print '%s: %s' % (result.type, result.message)
88+
pass #print(f'{result.type}: {result.message}')
8989
elif isinstance(result, dict):
9090
# Normal events are returned as dicts
91-
pass #print result
91+
pass #print(result)
9292
assert rr.is_preview == False
9393

9494
def test_results_docstring_sample(self):
@@ -101,10 +101,10 @@ def test_results_docstring_sample(self):
101101
for result in rr:
102102
if isinstance(result, results.Message):
103103
# Diagnostic messages may be returned in the results
104-
pass #print '%s: %s' % (result.type, result.message)
104+
pass #print(f'{result.type}: {result.message}')
105105
elif isinstance(result, dict):
106106
# Normal events are returned as dicts
107-
pass #print result
107+
pass #print(result)
108108
assert rr.is_preview == False
109109

110110
def test_preview_docstring_sample(self):
@@ -116,14 +116,14 @@ def test_preview_docstring_sample(self):
116116
for result in rr:
117117
if isinstance(result, results.Message):
118118
# Diagnostic messages may be returned in the results
119-
pass #print '%s: %s' % (result.type, result.message)
119+
pass #print(f'{result.type}: {result.message}')
120120
elif isinstance(result, dict):
121121
# Normal events are returned as dicts
122-
pass #print result
122+
pass #print(result)
123123
if rr.is_preview:
124-
pass #print "Preview of a running search job."
124+
pass #print("Preview of a running search job.")
125125
else:
126-
pass #print "Job is finished. Results are final."
126+
pass #print("Job is finished. Results are final.")
127127

128128
def test_oneshot_docstring_sample(self):
129129
from splunklib import client
@@ -133,10 +133,10 @@ def test_oneshot_docstring_sample(self):
133133
for result in rr:
134134
if isinstance(result, results.Message):
135135
# Diagnostic messages may be returned in the results
136-
pass #print '%s: %s' % (result.type, result.message)
136+
pass #print(f'{result.type}: {result.message}')
137137
elif isinstance(result, dict):
138138
# Normal events are returned as dicts
139-
pass #print result
139+
pass #print(result)
140140
assert rr.is_preview == False
141141

142142
def test_normal_job_with_garbage_fails(self):

utils/cmdopts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
# Print the given message to stderr, and optionally exit
2525
def error(message, exitcode = None):
26-
print("Error: %s" % message, file=sys.stderr)
26+
print(f"Error: {message}", file=sys.stderr)
2727
if exitcode is not None: sys.exit(exitcode)
2828

2929

0 commit comments

Comments
 (0)