Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bc0e910

Browse files
committed
Convert a pile of obvious "yes/no" functions to return bool.
1 parent 2f486b7 commit bc0e910

34 files changed

Lines changed: 117 additions & 122 deletions

Demo/pdist/cvslib.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,10 @@ def backup(self, file):
289289
os.rename(file, bfile)
290290

291291
def ignored(self, file):
292-
if os.path.isdir(file): return 1
292+
if os.path.isdir(file): return True
293293
for pat in self.IgnoreList:
294-
if fnmatch.fnmatch(file, pat): return 1
295-
return 0
294+
if fnmatch.fnmatch(file, pat): return True
295+
return Falso
296296

297297

298298
# hexify and unhexify are useful to print MD5 checksums in hex format

Lib/BaseHTTPServer.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def parse_request(self):
222222
are in self.command, self.path, self.request_version and
223223
self.headers.
224224
225-
Return value is 1 for success, 0 for failure; on failure, an
225+
Return True for success, False for failure; on failure, an
226226
error is sent back.
227227
228228
"""
@@ -239,30 +239,30 @@ def parse_request(self):
239239
[command, path, version] = words
240240
if version[:5] != 'HTTP/':
241241
self.send_error(400, "Bad request version (%s)" % `version`)
242-
return 0
242+
return False
243243
try:
244244
version_number = float(version.split('/', 1)[1])
245245
except ValueError:
246246
self.send_error(400, "Bad request version (%s)" % `version`)
247-
return 0
247+
return False
248248
if version_number >= 1.1 and self.protocol_version >= "HTTP/1.1":
249249
self.close_connection = 0
250250
if version_number >= 2.0:
251251
self.send_error(505,
252252
"Invalid HTTP Version (%f)" % version_number)
253-
return 0
253+
return False
254254
elif len(words) == 2:
255255
[command, path] = words
256256
self.close_connection = 1
257257
if command != 'GET':
258258
self.send_error(400,
259259
"Bad HTTP/0.9 request type (%s)" % `command`)
260-
return 0
260+
return False
261261
elif not words:
262-
return 0
262+
return False
263263
else:
264264
self.send_error(400, "Bad request syntax (%s)" % `requestline`)
265-
return 0
265+
return False
266266
self.command, self.path, self.request_version = command, path, version
267267

268268
# Deal with pipelining
@@ -283,7 +283,7 @@ def parse_request(self):
283283
elif (conntype.lower() == 'keep-alive' and
284284
self.protocol_version >= "HTTP/1.1"):
285285
self.close_connection = 0
286-
return 1
286+
return True
287287

288288
def handle_one_request(self):
289289
"""Handle a single HTTP request.

Lib/CGIHTTPServer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ def is_cgi(self):
8686
i = len(x)
8787
if path[:i] == x and (not path[i:] or path[i] == '/'):
8888
self.cgi_info = path[:i], path[i+1:]
89-
return 1
90-
return 0
89+
return True
90+
return False
9191

9292
cgi_directories = ['/cgi-bin', '/htbin']
9393

Lib/ConfigParser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,9 @@ def remove_section(self, section):
374374
"""Remove a file section."""
375375
if self.__sections.has_key(section):
376376
del self.__sections[section]
377-
return 1
377+
return True
378378
else:
379-
return 0
379+
return False
380380

381381
#
382382
# Regular expressions for parsing section headers and options. Note a

Lib/SocketServer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,10 @@ def handle_request(self):
226226
def verify_request(self, request, client_address):
227227
"""Verify the request. May be overridden.
228228
229-
Return true if we should proceed with this request.
229+
Return True if we should proceed with this request.
230230
231231
"""
232-
return 1
232+
return True
233233

234234
def process_request(self, request, client_address):
235235
"""Call finish_request.

Lib/asyncore.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def set_reuse_addr (self):
281281
# ==================================================
282282

283283
def readable (self):
284-
return 1
284+
return True
285285

286286
if os.name == 'mac':
287287
# The macintosh will select a listening socket for
@@ -290,7 +290,7 @@ def writable (self):
290290
return not self.accepting
291291
else:
292292
def writable (self):
293-
return 1
293+
return True
294294

295295
# ==================================================
296296
# socket object methods.

Lib/bdb.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,31 +92,31 @@ def dispatch_exception(self, frame, arg):
9292

9393
def stop_here(self, frame):
9494
if self.stopframe is None:
95-
return 1
95+
return True
9696
if frame is self.stopframe:
97-
return 1
97+
return True
9898
while frame is not None and frame is not self.stopframe:
9999
if frame is self.botframe:
100-
return 1
100+
return True
101101
frame = frame.f_back
102-
return 0
102+
return False
103103

104104
def break_here(self, frame):
105105
filename = self.canonic(frame.f_code.co_filename)
106106
if not self.breaks.has_key(filename):
107-
return 0
107+
return False
108108
lineno = frame.f_lineno
109109
if not lineno in self.breaks[filename]:
110-
return 0
110+
return False
111111
# flag says ok to delete temp. bp
112112
(bp, flag) = effective(filename, lineno, frame)
113113
if bp:
114114
self.currentbp = bp.number
115115
if (flag and bp.temporary):
116116
self.do_clear(str(bp.number))
117-
return 1
117+
return True
118118
else:
119-
return 0
119+
return False
120120

121121
def do_clear(self, arg):
122122
raise NotImplementedError, "subclass of bdb must implement do_clear()"

Lib/cgi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,8 +600,8 @@ def has_key(self, key):
600600
if self.list is None:
601601
raise TypeError, "not indexable"
602602
for item in self.list:
603-
if item.name == key: return 1
604-
return 0
603+
if item.name == key: return True
604+
return False
605605

606606
def __len__(self):
607607
"""Dictionary style len(x) support."""

Lib/code.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def runsource(self, source, filename="<input>", symbol="single"):
6666
object. The code is executed by calling self.runcode() (which
6767
also handles run-time exceptions, except for SystemExit).
6868
69-
The return value is 1 in case 2, 0 in the other cases (unless
69+
The return value is True in case 2, False in the other cases (unless
7070
an exception is raised). The return value can be used to
7171
decide whether to use sys.ps1 or sys.ps2 to prompt the next
7272
line.
@@ -77,15 +77,15 @@ def runsource(self, source, filename="<input>", symbol="single"):
7777
except (OverflowError, SyntaxError, ValueError):
7878
# Case 1
7979
self.showsyntaxerror(filename)
80-
return 0
80+
return False
8181

8282
if code is None:
8383
# Case 2
84-
return 1
84+
return True
8585

8686
# Case 3
8787
self.runcode(code)
88-
return 0
88+
return False
8989

9090
def runcode(self, code):
9191
"""Execute a code object.

Lib/distutils/command/build_py.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ def check_module (self, module, module_file):
190190
if not os.path.isfile(module_file):
191191
self.warn("file %s (for module %s) not found" %
192192
(module_file, module))
193-
return 0
193+
return False
194194
else:
195-
return 1
195+
return True
196196

197197
# check_module ()
198198

0 commit comments

Comments
 (0)