diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2019-07-09 16:22:51 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2019-07-10 06:57:24 -0400 |
commit | 6b226d85f5191cd27b20ad27caded8b407772a02 (patch) | |
tree | a7d2e58246fb5ef9b8128ff342e97968c4ace853 /coverage/misc.py | |
parent | 9bc6b93805a5f20a87211a315d00503eddab66dc (diff) | |
download | python-coveragepy-git-6b226d85f5191cd27b20ad27caded8b407772a02.tar.gz |
Remove the JSON data code
Diffstat (limited to 'coverage/misc.py')
-rw-r--r-- | coverage/misc.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/coverage/misc.py b/coverage/misc.py index ad7b834f..00e88fdb 100644 --- a/coverage/misc.py +++ b/coverage/misc.py @@ -9,7 +9,9 @@ import inspect import locale import os import os.path +import random import re +import socket import sys import types @@ -175,6 +177,18 @@ def output_encoding(outfile=None): return encoding +def filename_suffix(suffix): + """Compute a filename suffix for a data file.""" + if suffix is True: + # If data_suffix was a simple true value, then make a suffix with + # plenty of distinguishing information. We do this here in + # `save()` at the last minute so that the pid will be correct even + # if the process forks. + dice = random.Random(os.urandom(8)).randint(0, 999999) + suffix = "%s.%s.%06d" % (socket.gethostname(), os.getpid(), dice) + return suffix + + class Hasher(object): """Hashes Python data into md5.""" def __init__(self): |