MCPcopy Index your code
hub / github.com/python/cpython / PreservePyIni

Class PreservePyIni

Lib/test/test_launcher.py:149–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147
148
149class PreservePyIni:
150 def __init__(self, path, content):
151 self.path = Path(path)
152 self.content = content
153 self._preserved = None
154
155 def __enter__(self):
156 try:
157 self._preserved = self.path.read_bytes()
158 except FileNotFoundError:
159 self._preserved = None
160 self.path.write_text(self.content, encoding="utf-16")
161
162 def __exit__(self, *exc_info):
163 if self._preserved is None:
164 self.path.unlink()
165 else:
166 self.path.write_bytes(self._preserved)
167
168
169class RunPyMixin:

Callers 1

py_iniMethod · 0.85

Calls

no outgoing calls

Tested by 1

py_iniMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…