mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 22:02:27 +00:00
python-3.6.zip added from Github
README.cosmo contains the necessary links.
This commit is contained in:
parent
75fc601ff5
commit
0c4c56ff39
4219 changed files with 1968626 additions and 0 deletions
56
third_party/python/Lib/test/libregrtest/utils.py
vendored
Normal file
56
third_party/python/Lib/test/libregrtest/utils.py
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
import os.path
|
||||
import math
|
||||
import textwrap
|
||||
|
||||
|
||||
def format_duration(seconds):
|
||||
ms = math.ceil(seconds * 1e3)
|
||||
seconds, ms = divmod(ms, 1000)
|
||||
minutes, seconds = divmod(seconds, 60)
|
||||
hours, minutes = divmod(minutes, 60)
|
||||
|
||||
parts = []
|
||||
if hours:
|
||||
parts.append('%s hour' % hours)
|
||||
if minutes:
|
||||
parts.append('%s min' % minutes)
|
||||
if seconds:
|
||||
parts.append('%s sec' % seconds)
|
||||
if ms:
|
||||
parts.append('%s ms' % ms)
|
||||
if not parts:
|
||||
return '0 ms'
|
||||
|
||||
parts = parts[:2]
|
||||
return ' '.join(parts)
|
||||
|
||||
|
||||
def removepy(names):
|
||||
if not names:
|
||||
return
|
||||
for idx, name in enumerate(names):
|
||||
basename, ext = os.path.splitext(name)
|
||||
if ext == '.py':
|
||||
names[idx] = basename
|
||||
|
||||
|
||||
def count(n, word):
|
||||
if n == 1:
|
||||
return "%d %s" % (n, word)
|
||||
else:
|
||||
return "%d %ss" % (n, word)
|
||||
|
||||
|
||||
def printlist(x, width=70, indent=4, file=None):
|
||||
"""Print the elements of iterable x to stdout.
|
||||
|
||||
Optional arg width (default 70) is the maximum line length.
|
||||
Optional arg indent (default 4) is the number of blanks with which to
|
||||
begin each line.
|
||||
"""
|
||||
|
||||
blanks = ' ' * indent
|
||||
# Print the sorted list: 'x' may be a '--random' list or a set()
|
||||
print(textwrap.fill(' '.join(str(elt) for elt in sorted(x)), width,
|
||||
initial_indent=blanks, subsequent_indent=blanks),
|
||||
file=file)
|
Loading…
Add table
Add a link
Reference in a new issue