@@ -171,7 +171,7 @@ def set_pasv(self, val):
171
171
def sanitize (self , s ):
172
172
if s [:5 ] == 'pass ' or s [:5 ] == 'PASS ' :
173
173
i = len (s )
174
- while i > 5 and s [i - 1 ] in '\r \n ' :
174
+ while i > 5 and s [i - 1 ] in { '\r ' , ' \n '} :
175
175
i = i - 1
176
176
s = s [:5 ] + '*' * (i - 5 ) + s [i :]
177
177
return repr (s )
@@ -221,7 +221,7 @@ def getresp(self):
221
221
if self .debugging : print ('*resp*' , self .sanitize (resp ))
222
222
self .lastresp = resp [:3 ]
223
223
c = resp [:1 ]
224
- if c in ( '1' , '2' , '3' ) :
224
+ if c in { '1' , '2' , '3' } :
225
225
return resp
226
226
if c == '4' :
227
227
raise error_temp (resp )
@@ -245,7 +245,7 @@ def abort(self):
245
245
if self .debugging > 1 : print ('*put urgent*' , self .sanitize (line ))
246
246
self .sock .sendall (line , MSG_OOB )
247
247
resp = self .getmultiline ()
248
- if resp [:3 ] not in ( '426' , '225' , '226' ) :
248
+ if resp [:3 ] not in { '426' , '225' , '226' } :
249
249
raise error_proto (resp )
250
250
251
251
def sendcmd (self , cmd ):
@@ -375,7 +375,7 @@ def login(self, user = '', passwd = '', acct = ''):
375
375
if not user : user = 'anonymous'
376
376
if not passwd : passwd = ''
377
377
if not acct : acct = ''
378
- if user == 'anonymous' and passwd in ( '' , '-' ) :
378
+ if user == 'anonymous' and passwd in { '' , '-' } :
379
379
# If there is no anonymous ftp password specified
380
380
# then we'll just use anonymous@
381
381
# We don't send any other thing because:
@@ -534,7 +534,7 @@ def rename(self, fromname, toname):
534
534
def delete (self , filename ):
535
535
'''Delete a file.'''
536
536
resp = self .sendcmd ('DELE ' + filename )
537
- if resp [:3 ] in ( '250' , '200' ) :
537
+ if resp [:3 ] in { '250' , '200' } :
538
538
return resp
539
539
else :
540
540
raise error_reply (resp )
@@ -897,9 +897,9 @@ def ftpcp(source, sourcename, target, targetname = '', type = 'I'):
897
897
# transfer request.
898
898
# So: STOR before RETR, because here the target is a "user".
899
899
treply = target .sendcmd ('STOR ' + targetname )
900
- if treply [:3 ] not in ( '125' , '150' ) : raise error_proto # RFC 959
900
+ if treply [:3 ] not in { '125' , '150' } : raise error_proto # RFC 959
901
901
sreply = source .sendcmd ('RETR ' + sourcename )
902
- if sreply [:3 ] not in ( '125' , '150' ) : raise error_proto # RFC 959
902
+ if sreply [:3 ] not in { '125' , '150' } : raise error_proto # RFC 959
903
903
source .voidresp ()
904
904
target .voidresp ()
905
905
0 commit comments