20
20
basestring = str
21
21
22
22
from base64 import b64decode
23
- import shutil
24
23
from shutil import rmtree
25
24
import warnings
26
25
from contextlib import contextmanager
@@ -104,14 +103,14 @@ def __init__(self, firefox_profile=None, firefox_binary=None,
104
103
if executable_path != DEFAULT_EXECUTABLE_PATH :
105
104
warnings .warn ('executable_path has been deprecated, please pass in a Service object' ,
106
105
DeprecationWarning , stacklevel = 2 )
107
- if capabilities is not None or desired_capabilities is not None :
106
+ if capabilities or desired_capabilities :
108
107
warnings .warn ('capabilities and desired_capabilities have been deprecated, please pass in a Service object' ,
109
108
DeprecationWarning , stacklevel = 2 )
110
- if firefox_binary is not None :
109
+ if firefox_binary :
111
110
warnings .warn ('firefox_binary has been deprecated, please pass in a Service object' ,
112
111
DeprecationWarning , stacklevel = 2 )
113
112
self .binary = None
114
- if firefox_profile is not None :
113
+ if firefox_profile :
115
114
warnings .warn ('firefox_profile has been deprecated, please pass in an Options object' ,
116
115
DeprecationWarning , stacklevel = 2 )
117
116
self .profile = None
@@ -124,20 +123,20 @@ def __init__(self, firefox_profile=None, firefox_binary=None,
124
123
if service_log_path != DEFAULT_SERVICE_LOG_PATH :
125
124
warnings .warn ('service_log_path has been deprecated, please pass in a Service object' ,
126
125
DeprecationWarning , stacklevel = 2 )
127
- if service_args is not None :
126
+ if service_args :
128
127
warnings .warn ('service_args has been deprecated, please pass in a Service object' ,
129
128
DeprecationWarning , stacklevel = 2 )
130
129
131
130
self .service = service
132
131
133
132
# If desired capabilities is set, alias it to capabilities.
134
133
# If both are set ignore desired capabilities.
135
- if capabilities is None and desired_capabilities :
134
+ if not capabilities and desired_capabilities :
136
135
capabilities = desired_capabilities
137
136
138
- if capabilities is None :
137
+ if not capabilities :
139
138
capabilities = DesiredCapabilities .FIREFOX .copy ()
140
- if options is None :
139
+ if not options :
141
140
options = Options ()
142
141
143
142
capabilities = dict (capabilities )
@@ -146,20 +145,20 @@ def __init__(self, firefox_profile=None, firefox_binary=None,
146
145
self .binary = capabilities ["binary" ]
147
146
148
147
# options overrides capabilities
149
- if options is not None :
150
- if options .binary is not None :
148
+ if options :
149
+ if options .binary :
151
150
self .binary = options .binary
152
- if options .profile is not None :
151
+ if options .profile :
153
152
self .profile = options .profile
154
153
155
154
# firefox_binary and firefox_profile
156
155
# override options
157
- if firefox_binary is not None :
156
+ if firefox_binary :
158
157
if isinstance (firefox_binary , basestring ):
159
158
firefox_binary = FirefoxBinary (firefox_binary )
160
159
self .binary = firefox_binary
161
160
options .binary = firefox_binary
162
- if firefox_profile is not None :
161
+ if firefox_profile :
163
162
if isinstance (firefox_profile , basestring ):
164
163
firefox_profile = FirefoxProfile (firefox_profile )
165
164
self .profile = firefox_profile
@@ -171,7 +170,7 @@ def __init__(self, firefox_profile=None, firefox_binary=None,
171
170
if capabilities .get ("acceptInsecureCerts" ):
172
171
options .accept_insecure_certs = capabilities .get ("acceptInsecureCerts" )
173
172
174
- if self .service is None :
173
+ if not self .service :
175
174
self .service = Service (
176
175
executable_path ,
177
176
service_args = service_args ,
@@ -204,10 +203,10 @@ def quit(self):
204
203
else :
205
204
self .binary .kill ()
206
205
207
- if self .profile is not None :
206
+ if self .profile :
208
207
try :
209
208
rmtree (self .profile .path )
210
- if self .profile .tempfolder is not None :
209
+ if self .profile .tempfolder :
211
210
rmtree (self .profile .tempfolder )
212
211
except Exception as e :
213
212
print (str (e ))
0 commit comments