eric7/DebugClients/Python/coverage/misc.py

branch
eric7
changeset 8929
fcca2fa618bf
parent 8775
0802ae193343
child 9099
0e511e0e94a3
--- a/eric7/DebugClients/Python/coverage/misc.py	Sun Jan 16 20:28:42 2022 +0100
+++ b/eric7/DebugClients/Python/coverage/misc.py	Sat Jan 22 14:44:56 2022 +0100
@@ -12,9 +12,7 @@
 import locale
 import os
 import os.path
-import random
 import re
-import socket
 import sys
 import types
 
@@ -184,7 +182,7 @@
 
 def join_regex(regexes):
     """Combine a list of regexes into one that matches any of them."""
-    return "|".join("(?:%s)" % r for r in regexes)
+    return "|".join(f"(?:{r})" for r in regexes)
 
 
 def file_be_gone(path):
@@ -222,26 +220,6 @@
     return encoding
 
 
-def filename_suffix(suffix):
-    """Compute a filename suffix for a data file.
-
-    If `suffix` is a string or None, simply return it. If `suffix` is True,
-    then build a suffix incorporating the hostname, process id, and a random
-    number.
-
-    Returns a string or None.
-
-    """
-    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:
     """Hashes Python data for fingerprinting."""
     def __init__(self):
@@ -415,3 +393,14 @@
     Returns the sorted list of items.
     """
     return sorted(items, key=lambda pair: (human_key(pair[0]), pair[1]), reverse=reverse)
+
+
+def plural(n, thing="", things=""):
+    """Pluralize a word.
+
+    If n is 1, return thing.  Otherwise return things, or thing+s.
+    """
+    if n == 1:
+        return thing
+    else:
+        return things or (thing + "s")

eric ide

mercurial