MCPcopy Index your code
hub / github.com/RustPython/RustPython / _RandomNameSequence

Class _RandomNameSequence

Lib/tempfile.py:132–154  ·  view source on GitHub ↗

An instance of _RandomNameSequence generates an endless sequence of unpredictable strings which can safely be incorporated into file names. Each string is eight characters long. Multiple threads can safely use the same instance at the same time. _RandomNameSequence is an iterator.

Source from the content-addressed store, hash-verified

130
131
132class _RandomNameSequence:
133 """An instance of _RandomNameSequence generates an endless
134 sequence of unpredictable strings which can safely be incorporated
135 into file names. Each string is eight characters long. Multiple
136 threads can safely use the same instance at the same time.
137
138 _RandomNameSequence is an iterator."""
139
140 characters = "abcdefghijklmnopqrstuvwxyz0123456789_"
141
142 @property
143 def rng(self):
144 cur_pid = _os.getpid()
145 if cur_pid != getattr(self, '_rng_pid', None):
146 self._rng = _Random()
147 self._rng_pid = cur_pid
148 return self._rng
149
150 def __iter__(self):
151 return self
152
153 def __next__(self):
154 return ''.join(self.rng.choices(self.characters, k=8))
155
156def _candidate_tempdir_list():
157 """Generate a list of candidate temporary directories which

Callers 2

_get_default_tempdirFunction · 0.85
_get_candidate_namesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected