@@ -681,7 +681,7 @@ def splunk_version(self):
681681 :return: A ``tuple`` of ``integers``.
682682 """
683683 if self ._splunk_version is None :
684- self ._splunk_version = tuple ([ int (p ) for p in self .info ['version' ].split ('.' )] )
684+ self ._splunk_version = tuple (int (p ) for p in self .info ['version' ].split ('.' ))
685685 return self ._splunk_version
686686
687687 @property
@@ -977,11 +977,9 @@ def _load_atom_entry(self, response):
977977 elem = _load_atom (response , XNAME_ENTRY )
978978 if isinstance (elem , list ):
979979 apps = [ele .entry .content .get ('eai:appName' ) for ele in elem ]
980-
981980 raise AmbiguousReferenceException (
982981 f"Fetch from server returned multiple entries for name '{ elem [0 ].entry .title } ' in apps { apps } ." )
983- else :
984- return elem .entry
982+ return elem .entry
985983
986984 # Load the entity state record from the given response
987985 def _load_state (self , response ):
@@ -1022,8 +1020,7 @@ def _proper_namespace(self, owner=None, app=None, sharing=None):
10221020 return (self .service .namespace ['owner' ],
10231021 self .service .namespace ['app' ],
10241022 self .service .namespace ['sharing' ])
1025- else :
1026- return owner , app , sharing
1023+ return owner , app , sharing
10271024
10281025 def delete (self ):
10291026 owner , app , sharing = self ._proper_namespace ()
@@ -1125,8 +1122,8 @@ def read(self, response):
11251122 # In lower layers of the SDK, we end up trying to URL encode
11261123 # text to be dispatched via HTTP. However, these links are already
11271124 # URL encoded when they arrive, and we need to mark them as such.
1128- unquoted_links = dict ([ (k , UrlEncoded (v , skip_encode = True ))
1129- for k , v in list (results ['links' ].items ())] )
1125+ unquoted_links = dict ((k , UrlEncoded (v , skip_encode = True ))
1126+ for k , v in list (results ['links' ].items ()))
11301127 results ['links' ] = unquoted_links
11311128 return results
11321129
@@ -1728,8 +1725,7 @@ def __getitem__(self, key):
17281725 except HTTPError as he :
17291726 if he .status == 404 : # No entity matching key
17301727 raise KeyError (key )
1731- else :
1732- raise
1728+ raise
17331729
17341730 def __contains__ (self , key ):
17351731 # configs/conf-{name} never returns a 404. We have to post to properties/{name}
@@ -2230,8 +2226,7 @@ def __getitem__(self, key):
22302226 except HTTPError as he :
22312227 if he .status == 404 : # No entity matching kind and key
22322228 raise KeyError ((key , kind ))
2233- else :
2234- raise
2229+ raise
22352230 else :
22362231 # Iterate over all the kinds looking for matches.
22372232 kind = None
@@ -2243,22 +2238,19 @@ def __getitem__(self, key):
22432238 entries = self ._load_list (response )
22442239 if len (entries ) > 1 :
22452240 raise AmbiguousReferenceException (f"Found multiple inputs of kind { kind } named { key } ." )
2246- elif len (entries ) == 0 :
2241+ if len (entries ) == 0 :
22472242 pass
2248- else :
2249- if candidate is not None : # Already found at least one candidate
2250- raise AmbiguousReferenceException (
2251- f"Found multiple inputs named { key } , please specify a kind" )
2252- candidate = entries [0 ]
2243+ if candidate is not None : # Already found at least one candidate
2244+ raise AmbiguousReferenceException (
2245+ f"Found multiple inputs named { key } , please specify a kind" )
2246+ candidate = entries [0 ]
22532247 except HTTPError as he :
22542248 if he .status == 404 :
22552249 pass # Just carry on to the next kind.
2256- else :
2257- raise
2250+ raise
22582251 if candidate is None :
22592252 raise KeyError (key ) # Never found a match.
2260- else :
2261- return candidate
2253+ return candidate
22622254
22632255 def __contains__ (self , key ):
22642256 if isinstance (key , tuple ) and len (key ) == 2 :
@@ -2278,13 +2270,11 @@ def __contains__(self, key):
22782270 entries = self ._load_list (response )
22792271 if len (entries ) > 0 :
22802272 return True
2281- else :
2282- pass
2273+ pass
22832274 except HTTPError as he :
22842275 if he .status == 404 :
22852276 pass # Just carry on to the next kind.
2286- else :
2287- raise
2277+ raise
22882278 return False
22892279
22902280 def create (self , name , kind , ** kwargs ):
@@ -2422,12 +2412,11 @@ def _get_kind_list(self, subpath=None):
24222412 # The "tcp/ssl" endpoint is not a real input collection.
24232413 if entry .title == 'all' or this_subpath == ['tcp' , 'ssl' ]:
24242414 continue
2425- elif 'create' in [x .rel for x in entry .link ]:
2415+ if 'create' in [x .rel for x in entry .link ]:
24262416 path = '/' .join (subpath + [entry .title ])
24272417 kinds .append (path )
2428- else :
2429- subkinds = self ._get_kind_list (subpath + [entry .title ])
2430- kinds .extend (subkinds )
2418+ subkinds = self ._get_kind_list (subpath + [entry .title ])
2419+ kinds .extend (subkinds )
24312420 return kinds
24322421
24332422 @property
@@ -2471,10 +2460,9 @@ def kindpath(self, kind):
24712460 """
24722461 if kind == 'tcp' :
24732462 return UrlEncoded ('tcp/raw' , skip_encode = True )
2474- elif kind == 'splunktcp' :
2463+ if kind == 'splunktcp' :
24752464 return UrlEncoded ('tcp/cooked' , skip_encode = True )
2476- else :
2477- return UrlEncoded (kind , skip_encode = True )
2465+ return UrlEncoded (kind , skip_encode = True )
24782466
24792467 def list (self , * kinds , ** kwargs ):
24802468 """Returns a list of inputs that are in the :class:`Inputs` collection.
@@ -2569,8 +2557,7 @@ def list(self, *kinds, **kwargs):
25692557 except HTTPError as e :
25702558 if e .status == 404 :
25712559 continue # No inputs of this kind
2572- else :
2573- raise
2560+ raise
25742561
25752562 entries = _load_atom_entries (response )
25762563 if entries is None : continue # No inputs to process
@@ -3111,15 +3098,13 @@ def __contains__(self, name):
31113098 args = self .state .content ['endpoints' ]['args' ]
31123099 if name in args :
31133100 return True
3114- else :
3115- return Entity .__contains__ (self , name )
3101+ return Entity .__contains__ (self , name )
31163102
31173103 def __getitem__ (self , name ):
31183104 args = self .state .content ['endpoint' ]['args' ]
31193105 if name in args :
31203106 return args ['item' ]
3121- else :
3122- return Entity .__getitem__ (self , name )
3107+ return Entity .__getitem__ (self , name )
31233108
31243109 @property
31253110 def arguments (self ):
@@ -3283,8 +3268,7 @@ def suppressed(self):
32833268 r = self ._run_action ("suppress" )
32843269 if r .suppressed == "1" :
32853270 return int (r .expiration )
3286- else :
3287- return 0
3271+ return 0
32883272
32893273 def unsuppress (self ):
32903274 """Cancels suppression and makes this search run as scheduled.
0 commit comments