@@ -212,10 +212,9 @@ def _load_atom_entries(response):
212212 # its state wrapped in another element, but at the top level.
213213 # For example, in XML, it returns <entry>...</entry> instead of
214214 # <feed><entry>...</entry></feed>.
215- else :
216- entries = r .get ('entry' , None )
217- if entries is None : return None
218- return entries if isinstance (entries , list ) else [entries ]
215+ entries = r .get ('entry' , None )
216+ if entries is None : return None
217+ return entries if isinstance (entries , list ) else [entries ]
219218
220219
221220# Load the sid from the body of the given response
@@ -530,8 +529,7 @@ def modular_input_kinds(self):
530529 """
531530 if self .splunk_version >= (5 ,):
532531 return ReadOnlyCollection (self , PATH_MODULAR_INPUTS , item = ModularInputKind )
533- else :
534- raise IllegalOperationException ("Modular inputs are not supported before Splunk version 5." )
532+ raise IllegalOperationException ("Modular inputs are not supported before Splunk version 5." )
535533
536534 @property
537535 def storage_passwords (self ):
@@ -926,7 +924,6 @@ def __init__(self, service, path, **kwargs):
926924 self ._state = None
927925 if not kwargs .get ('skip_refresh' , False ):
928926 self .refresh (kwargs .get ('state' , None )) # "Prefresh"
929- return
930927
931928 def __contains__ (self , item ):
932929 try :
@@ -963,10 +960,9 @@ def __getattr__(self, key):
963960 # case we try to find it in self.content and then self.defaults.
964961 if key in self .state .content :
965962 return self .state .content [key ]
966- elif key in self .defaults :
963+ if key in self .defaults :
967964 return self .defaults [key ]
968- else :
969- raise AttributeError (key )
965+ raise AttributeError (key )
970966
971967 def __getitem__ (self , key ):
972968 # getattr attempts to find a field on the object in the normal way,
@@ -1022,8 +1018,7 @@ def _proper_namespace(self, owner=None, app=None, sharing=None):
10221018 return (self ._state .access .owner ,
10231019 self ._state .access .app ,
10241020 self ._state .access .sharing )
1025- else :
1026- return (self .service .namespace ['owner' ],
1021+ return (self .service .namespace ['owner' ],
10271022 self .service .namespace ['app' ],
10281023 self .service .namespace ['sharing' ])
10291024 else :
@@ -1272,15 +1267,13 @@ def __getitem__(self, key):
12721267 if len (entries ) > 1 :
12731268 raise AmbiguousReferenceException (
12741269 f"Found multiple entities named '{ key } '; please specify a namespace." )
1275- elif len (entries ) == 0 :
1270+ if len (entries ) == 0 :
12761271 raise KeyError (key )
1277- else :
1278- return entries [0 ]
1272+ return entries [0 ]
12791273 except HTTPError as he :
12801274 if he .status == 404 : # No entity matching key and namespace.
12811275 raise KeyError (key )
1282- else :
1283- raise
1276+ raise
12841277
12851278 def __iter__ (self , ** kwargs ):
12861279 """Iterate over the entities in the collection.
@@ -1344,10 +1337,9 @@ def _entity_path(self, state):
13441337 raw_path = parse .unquote (state .links .alternate )
13451338 if 'servicesNS/' in raw_path :
13461339 return _trailing (raw_path , 'servicesNS/' , '/' , '/' )
1347- elif 'services/' in raw_path :
1340+ if 'services/' in raw_path :
13481341 return _trailing (raw_path , 'services/' )
1349- else :
1350- return raw_path
1342+ return raw_path
13511343
13521344 def _load_list (self , response ):
13531345 """Converts *response* to a list of entities.
@@ -1596,14 +1588,13 @@ def create(self, name, **params):
15961588 # This endpoint doesn't return the content of the new
15971589 # item. We have to go fetch it ourselves.
15981590 return self [name ]
1599- else :
1600- entry = atom .entry
1601- state = _parse_atom_entry (entry )
1602- entity = self .item (
1603- self .service ,
1604- self ._entity_path (state ),
1605- state = state )
1606- return entity
1591+ entry = atom .entry
1592+ state = _parse_atom_entry (entry )
1593+ entity = self .item (
1594+ self .service ,
1595+ self ._entity_path (state ),
1596+ state = state )
1597+ return entity
16071598
16081599 def delete (self , name , ** params ):
16091600 """Deletes a specified entity from the collection.
@@ -1644,8 +1635,7 @@ def delete(self, name, **params):
16441635 # KeyError.
16451636 if he .status == 404 :
16461637 raise KeyError (f"No such entity { name } " )
1647- else :
1648- raise
1638+ raise
16491639 return self
16501640
16511641 def get (self , name = "" , owner = None , app = None , sharing = None , ** query ):
@@ -1749,8 +1739,7 @@ def __contains__(self, key):
17491739 except HTTPError as he :
17501740 if he .status == 404 : # No entity matching key
17511741 return False
1752- else :
1753- raise
1742+ raise
17541743
17551744 def create (self , name ):
17561745 """ Creates a configuration file named *name*.
@@ -1771,10 +1760,9 @@ def create(self, name):
17711760 response = self .post (__conf = name )
17721761 if response .status == 303 :
17731762 return self [name ]
1774- elif response .status == 201 :
1763+ if response .status == 201 :
17751764 return ConfigurationFile (self .service , PATH_CONF % name , item = Stanza , state = {'title' : name })
1776- else :
1777- raise ValueError (f"Unexpected status code { response .status } returned from creating a stanza" )
1765+ raise ValueError (f"Unexpected status code { response .status } returned from creating a stanza" )
17781766
17791767 def delete (self , key ):
17801768 """Raises `IllegalOperationException`."""
@@ -2203,7 +2191,7 @@ def update(self, **kwargs):
22032191
22042192 if 'restrictToHost' in kwargs :
22052193 raise IllegalOperationException ("Cannot set restrictToHost on an existing input with the SDK." )
2206- elif 'restrictToHost' in self ._state .content and self .kind != 'udp' :
2194+ if 'restrictToHost' in self ._state .content and self .kind != 'udp' :
22072195 to_update ['restrictToHost' ] = self ._state .content ['restrictToHost' ]
22082196
22092197 # Do the actual update operation.
@@ -2235,10 +2223,9 @@ def __getitem__(self, key):
22352223 entries = self ._load_list (response )
22362224 if len (entries ) > 1 :
22372225 raise AmbiguousReferenceException (f"Found multiple inputs of kind { kind } named { key } ." )
2238- elif len (entries ) == 0 :
2226+ if len (entries ) == 0 :
22392227 raise KeyError ((key , kind ))
2240- else :
2241- return entries [0 ]
2228+ return entries [0 ]
22422229 except HTTPError as he :
22432230 if he .status == 404 : # No entity matching kind and key
22442231 raise KeyError ((key , kind ))
0 commit comments