##// END OF EJS Templates
check-code: flag 0/1 used as constant Boolean expression
Martin Geisler -
r14494:1ffeeb91 default
parent child Browse files
Show More
@@ -163,6 +163,8 b' pypats = ['
163 (r' is\s+(not\s+)?["\'0-9-]', "object comparison with literal"),
163 (r' is\s+(not\s+)?["\'0-9-]', "object comparison with literal"),
164 (r' [=!]=\s+(True|False|None)',
164 (r' [=!]=\s+(True|False|None)',
165 "comparison with singleton, use 'is' or 'is not' instead"),
165 "comparison with singleton, use 'is' or 'is not' instead"),
166 (r'^\s*(while|if) [01]:',
167 "use True/False for constant Boolean expression"),
166 (r'opener\([^)]*\).read\(',
168 (r'opener\([^)]*\).read\(',
167 "use opener.read() instead"),
169 "use opener.read() instead"),
168 (r'opener\([^)]*\).write\(',
170 (r'opener\([^)]*\).write\(',
@@ -8,7 +8,7 b' def timer(func, title=None):'
8 results = []
8 results = []
9 begin = time.time()
9 begin = time.time()
10 count = 0
10 count = 0
11 while 1:
11 while True:
12 ostart = os.times()
12 ostart = os.times()
13 cstart = time.time()
13 cstart = time.time()
14 r = func()
14 r = func()
@@ -227,7 +227,7 b' class convert_cvs(converter_source):'
227
227
228 data = ""
228 data = ""
229 mode = None
229 mode = None
230 while 1:
230 while True:
231 line = self.readp.readline()
231 line = self.readp.readline()
232 if line.startswith("Created ") or line.startswith("Updated "):
232 if line.startswith("Created ") or line.startswith("Updated "):
233 self.readp.readline() # path
233 self.readp.readline() # path
@@ -591,7 +591,7 b' class DNSIncoming(object):'
591 next = -1
591 next = -1
592 first = off
592 first = off
593
593
594 while 1:
594 while True:
595 len = ord(self.data[off])
595 len = ord(self.data[off])
596 off += 1
596 off += 1
597 if len == 0:
597 if len == 0:
@@ -939,7 +939,7 b' class Reaper(threading.Thread):'
939 self.start()
939 self.start()
940
940
941 def run(self):
941 def run(self):
942 while 1:
942 while True:
943 self.zeroconf.wait(10 * 1000)
943 self.zeroconf.wait(10 * 1000)
944 if globals()['_GLOBAL_DONE']:
944 if globals()['_GLOBAL_DONE']:
945 return
945 return
@@ -1003,7 +1003,7 b' class ServiceBrowser(threading.Thread):'
1003 self.zeroconf.notifyAll()
1003 self.zeroconf.notifyAll()
1004
1004
1005 def run(self):
1005 def run(self):
1006 while 1:
1006 while True:
1007 event = None
1007 event = None
1008 now = currentTimeMillis()
1008 now = currentTimeMillis()
1009 if len(self.list) == 0 and self.nextTime > now:
1009 if len(self.list) == 0 and self.nextTime > now:
@@ -76,7 +76,7 b' def ancestor(a, b, pfunc):'
76 # increment each ancestor list until it is closer to root than
76 # increment each ancestor list until it is closer to root than
77 # the other, or they match
77 # the other, or they match
78 try:
78 try:
79 while 1:
79 while True:
80 if gx[0] == gy[0]:
80 if gx[0] == gy[0]:
81 for v in gx[1]:
81 for v in gx[1]:
82 if v in gy[1]:
82 if v in gy[1]:
@@ -33,7 +33,7 b' class bundlerevlog(revlog.revlog):'
33 self.basemap = {}
33 self.basemap = {}
34 n = len(self)
34 n = len(self)
35 chain = None
35 chain = None
36 while 1:
36 while True:
37 chunkdata = bundle.deltachunk(chain)
37 chunkdata = bundle.deltachunk(chain)
38 if not chunkdata:
38 if not chunkdata:
39 break
39 break
@@ -185,7 +185,7 b' class bundlerepository(localrepo.localre'
185
185
186 try:
186 try:
187 fptemp.write("HG10UN")
187 fptemp.write("HG10UN")
188 while 1:
188 while True:
189 chunk = self.bundle.read(2**18)
189 chunk = self.bundle.read(2**18)
190 if not chunk:
190 if not chunk:
191 break
191 break
@@ -232,13 +232,13 b' class bundlerepository(localrepo.localre'
232 def file(self, f):
232 def file(self, f):
233 if not self.bundlefilespos:
233 if not self.bundlefilespos:
234 self.bundle.seek(self.filestart)
234 self.bundle.seek(self.filestart)
235 while 1:
235 while True:
236 chunkdata = self.bundle.filelogheader()
236 chunkdata = self.bundle.filelogheader()
237 if not chunkdata:
237 if not chunkdata:
238 break
238 break
239 fname = chunkdata['filename']
239 fname = chunkdata['filename']
240 self.bundlefilespos[fname] = self.bundle.tell()
240 self.bundlefilespos[fname] = self.bundle.tell()
241 while 1:
241 while True:
242 c = self.bundle.deltachunk(None)
242 c = self.bundle.deltachunk(None)
243 if not c:
243 if not c:
244 break
244 break
@@ -91,7 +91,7 b' def writebundle(cg, filename, bundletype'
91 while not empty or count <= 2:
91 while not empty or count <= 2:
92 empty = True
92 empty = True
93 count += 1
93 count += 1
94 while 1:
94 while True:
95 chunk = getchunk(cg)
95 chunk = getchunk(cg)
96 if not chunk:
96 if not chunk:
97 break
97 break
@@ -1342,7 +1342,7 b' def debugbundle(ui, bundlepath, all=None'
1342 def showchunks(named):
1342 def showchunks(named):
1343 ui.write("\n%s\n" % named)
1343 ui.write("\n%s\n" % named)
1344 chain = None
1344 chain = None
1345 while 1:
1345 while True:
1346 chunkdata = gen.deltachunk(chain)
1346 chunkdata = gen.deltachunk(chain)
1347 if not chunkdata:
1347 if not chunkdata:
1348 break
1348 break
@@ -1361,7 +1361,7 b' def debugbundle(ui, bundlepath, all=None'
1361 showchunks("changelog")
1361 showchunks("changelog")
1362 chunkdata = gen.manifestheader()
1362 chunkdata = gen.manifestheader()
1363 showchunks("manifest")
1363 showchunks("manifest")
1364 while 1:
1364 while True:
1365 chunkdata = gen.filelogheader()
1365 chunkdata = gen.filelogheader()
1366 if not chunkdata:
1366 if not chunkdata:
1367 break
1367 break
@@ -1370,7 +1370,7 b' def debugbundle(ui, bundlepath, all=None'
1370 else:
1370 else:
1371 chunkdata = gen.changelogheader()
1371 chunkdata = gen.changelogheader()
1372 chain = None
1372 chain = None
1373 while 1:
1373 while True:
1374 chunkdata = gen.deltachunk(chain)
1374 chunkdata = gen.deltachunk(chain)
1375 if not chunkdata:
1375 if not chunkdata:
1376 break
1376 break
@@ -134,7 +134,7 b' def copies(repo, c1, c2, ca, checkdirs=F'
134 if f2r is None:
134 if f2r is None:
135 f2 = g2.next()
135 f2 = g2.next()
136
136
137 while 1:
137 while True:
138 f1r, f2r = f1.rev(), f2.rev()
138 f1r, f2r = f1.rev(), f2.rev()
139 if f1r > f2r:
139 if f1r > f2r:
140 f1 = g1.next()
140 f1 = g1.next()
@@ -33,7 +33,7 b' class webproto(object):'
33 args = self.req.form.copy()
33 args = self.req.form.copy()
34 chunks = []
34 chunks = []
35 i = 1
35 i = 1
36 while 1:
36 while True:
37 h = self.req.env.get('HTTP_X_HGARG_' + str(i))
37 h = self.req.env.get('HTTP_X_HGARG_' + str(i))
38 if h is None:
38 if h is None:
39 break
39 break
@@ -50,7 +50,7 b' class webproto(object):'
50 sys.stderr = sys.stdout = cStringIO.StringIO()
50 sys.stderr = sys.stdout = cStringIO.StringIO()
51 def groupchunks(self, cg):
51 def groupchunks(self, cg):
52 z = zlib.compressobj()
52 z = zlib.compressobj()
53 while 1:
53 while True:
54 chunk = cg.read(4096)
54 chunk = cg.read(4096)
55 if not chunk:
55 if not chunk:
56 break
56 break
@@ -507,7 +507,7 b' class HTTPResponse(httplib.HTTPResponse)'
507 def readlines(self, sizehint = 0):
507 def readlines(self, sizehint = 0):
508 total = 0
508 total = 0
509 list = []
509 list = []
510 while 1:
510 while True:
511 line = self.readline()
511 line = self.readline()
512 if not line:
512 if not line:
513 break
513 break
@@ -654,7 +654,7 b' def continuity(url):'
654
654
655 fo = urllib2.urlopen(url)
655 fo = urllib2.urlopen(url)
656 foo = ''
656 foo = ''
657 while 1:
657 while True:
658 f = fo.readline()
658 f = fo.readline()
659 if f:
659 if f:
660 foo = foo + f
660 foo = foo + f
@@ -1309,7 +1309,7 b' class localrepository(repo.repository):'
1309 b = []
1309 b = []
1310 for n in nodes:
1310 for n in nodes:
1311 t = n
1311 t = n
1312 while 1:
1312 while True:
1313 p = self.changelog.parents(n)
1313 p = self.changelog.parents(n)
1314 if p[1] != nullid or p[0] == nullid:
1314 if p[1] != nullid or p[0] == nullid:
1315 b.append((t, n, p[0], p[1]))
1315 b.append((t, n, p[0], p[1]))
@@ -1777,7 +1777,7 b' class localrepository(repo.repository):'
1777 pr.total = efiles
1777 pr.total = efiles
1778 source.callback = None
1778 source.callback = None
1779
1779
1780 while 1:
1780 while True:
1781 chunkdata = source.filelogheader()
1781 chunkdata = source.filelogheader()
1782 if not chunkdata:
1782 if not chunkdata:
1783 break
1783 break
@@ -51,7 +51,7 b' class lock(object):'
51
51
52 def lock(self):
52 def lock(self):
53 timeout = self.timeout
53 timeout = self.timeout
54 while 1:
54 while True:
55 try:
55 try:
56 self.trylock()
56 self.trylock()
57 return 1
57 return 1
@@ -346,7 +346,7 b' class linereader(object):'
346 return self.fp.readline()
346 return self.fp.readline()
347
347
348 def __iter__(self):
348 def __iter__(self):
349 while 1:
349 while True:
350 l = self.readline()
350 l = self.readline()
351 if not l:
351 if not l:
352 break
352 break
@@ -1151,7 +1151,7 b' class revlog(object):'
1151 try:
1151 try:
1152 # loop through our set of deltas
1152 # loop through our set of deltas
1153 chain = None
1153 chain = None
1154 while 1:
1154 while True:
1155 chunkdata = bundle.deltachunk(chain)
1155 chunkdata = bundle.deltachunk(chain)
1156 if not chunkdata:
1156 if not chunkdata:
1157 break
1157 break
@@ -88,7 +88,7 b' class sshrepository(wireproto.wirereposi'
88 break
88 break
89
89
90 def readerr(self):
90 def readerr(self):
91 while 1:
91 while True:
92 size = util.fstat(self.pipee).st_size
92 size = util.fstat(self.pipee).st_size
93 if size == 0:
93 if size == 0:
94 break
94 break
@@ -148,7 +148,7 b' class sshrepository(wireproto.wirereposi'
148 r = self._call(cmd, **args)
148 r = self._call(cmd, **args)
149 if r:
149 if r:
150 return '', r
150 return '', r
151 while 1:
151 while True:
152 d = fp.read(4096)
152 d = fp.read(4096)
153 if not d:
153 if not d:
154 break
154 break
@@ -193,7 +193,7 b' class sshrepository(wireproto.wirereposi'
193 d = self._call("addchangegroup")
193 d = self._call("addchangegroup")
194 if d:
194 if d:
195 self._abort(error.RepoError(_("push refused: %s") % d))
195 self._abort(error.RepoError(_("push refused: %s") % d))
196 while 1:
196 while True:
197 d = cg.read(4096)
197 d = cg.read(4096)
198 if not d:
198 if not d:
199 break
199 break
@@ -29,7 +29,7 b' for filename in sys.argv[1:]:'
29
29
30 m = md5()
30 m = md5()
31 try:
31 try:
32 while 1:
32 while True:
33 data = fp.read(8192)
33 data = fp.read(8192)
34 if not data:
34 if not data:
35 break
35 break
@@ -95,7 +95,7 b' class ProxyHandler (BaseHTTPServer.BaseH'
95 iw = [self.connection, soc]
95 iw = [self.connection, soc]
96 ow = []
96 ow = []
97 count = 0
97 count = 0
98 while 1:
98 while True:
99 count += 1
99 count += 1
100 (ins, _, exs) = select.select(iw, ow, iw, 3)
100 (ins, _, exs) = select.select(iw, ow, iw, 3)
101 if exs:
101 if exs:
General Comments 0
You need to be logged in to leave comments. Login now