mirror of
https://github.com/python/cpython.git
synced 2025-12-09 02:35:14 +00:00
Simplify code
This commit is contained in:
parent
e1f849c7d2
commit
572895b8eb
1 changed files with 3 additions and 14 deletions
|
|
@ -108,30 +108,19 @@ class _RandomNameSequence:
|
||||||
|
|
||||||
_RandomNameSequence is an iterator."""
|
_RandomNameSequence is an iterator."""
|
||||||
|
|
||||||
characters = ("abcdefghijklmnopqrstuvwxyz" +
|
characters = "abcdefghijklmnopqrstuvwxyz0123456789_"
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
|
|
||||||
"0123456789_")
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.mutex = _allocate_lock()
|
|
||||||
self.rng = _Random()
|
self.rng = _Random()
|
||||||
self.normcase = _os.path.normcase
|
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __next__(self):
|
def __next__(self):
|
||||||
m = self.mutex
|
|
||||||
c = self.characters
|
c = self.characters
|
||||||
choose = self.rng.choice
|
choose = self.rng.choice
|
||||||
|
|
||||||
m.acquire()
|
|
||||||
try:
|
|
||||||
letters = [choose(c) for dummy in "123456"]
|
letters = [choose(c) for dummy in "123456"]
|
||||||
finally:
|
return ''.join(letters)
|
||||||
m.release()
|
|
||||||
|
|
||||||
return self.normcase(''.join(letters))
|
|
||||||
|
|
||||||
def _candidate_tempdir_list():
|
def _candidate_tempdir_list():
|
||||||
"""Generate a list of candidate temporary directories which
|
"""Generate a list of candidate temporary directories which
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue