global _path_created
# Detect a common bug -- name is None
- if not isinstance(name, StringTypes):
+ if not isinstance(name, StringTypes):
raise DistutilsInternalError, \
"mkpath: 'name' must be a string (got %r)" % (name,)
sha256 = __get_builtin_constructor('sha256')
sha384 = __get_builtin_constructor('sha384')
sha512 = __get_builtin_constructor('sha512')
-
result = [None] * k
setsize = 21 # size of a small set minus size of an empty list
if k > 5:
- setsize += 4 ** _ceil(_log(k * 3, 4)) # table size for big sets
+ setsize += 4 ** _ceil(_log(k * 3, 4)) # table size for big sets
if n <= setsize: # is an n-length list smaller than a k-length set
pool = list(population)
for i in xrange(k): # invariant: non-selected at [0,n-i)
class StopCompares:
def __eq__(self, other):
raise DoNotTestEq
-
+
checkfirst = self.type2test([1, StopCompares()])
self.assert_(1 in checkfirst)
checklast = self.type2test([StopCompares(), 1])
Ye olde Fibonacci generator, tee style.
>>> def fib():
-...
+...
... def _isum(g, h):
... while 1:
... yield g.next() + h.next()
-...
+...
... def _fib():
... yield 1
... yield 2
... fibTail.next() # throw first away
... for res in _isum(fibHead, fibTail):
... yield res
-...
+...
... fibHead, fibTail, fibRes = tee(_fib(), 3)
... return fibRes
test_scaled_msg(scale=106, name='[small data]')
test_scaled_msg(scale=creatorFunc().digest_size, name='[digest_size data]')
test_scaled_msg(scale=10, name='[tiny data]')
-
f.seek(0, 2)
verify(f.tell() == 512, 'Underlying file not truncated')
f.close()
- verify(m.size() == 512, 'New size not reflected in file')
+ verify(m.size() == 512, 'New size not reflected in file')
m.close()
def parse_http_list(s):
"""Parse lists as described by RFC 2068 Section 2.
-
+
In particular, parse comma-separated lists where the elements of
the list may include quoted-strings. A quoted-string could
contain a comma. A non-quoted string could have quotes in the
if cur == '"':
quote = True
-
+
part += cur
# append last part
if filename.endswith(".py"):
yield os.path.join(root, filename)
pysource = pysource()
-
-
+
+
print >>sys.stderr, ("The pysource module is not available; "
"no sophisticated Python source file search will be done.")
line1 = infile.readline()
line2 = infile.readline()
-
+
if get_declaration(line1) or get_declaration(line2):
# the file does have an encoding declaration, so trust it
infile.close()
return False
-
+
# check the whole file for non-ASCII characters
rest = infile.read()
infile.close()
-
+
if has_correct_encoding(line1+line2+rest, "ascii"):
return False
-
+
return True
result = needs_declaration(fullpath)
if result:
print fullpath
-
-
line = infile.readline()
infile.close()
-
+
if binary_re.search(line):
# file appears to be binary
print_debug("%s: appears to be binary" % fullpath)
return False
-
+
if fullpath.endswith(".py") or fullpath.endswith(".pyw"):
return True
elif "python" in line:
paths: a list of files and/or directories to be checked.
is_python: a function that takes a file name and checks whether it is a
Python source file
- exclude_dirs: a list of directory base names that should be excluded in
+ exclude_dirs: a list of directory base names that should be excluded in
the search
"""
if exclude_dirs is None:
exclude_dirs=[]
-
+
for path in paths:
print_debug("testing: %s" % path)
if os.path.isfile(path):