INNER CODE UNIT · Python
_cleanup
GoogleCloudPlatform/terraform-python-testing-helper · tftest.py:303
def _cleanup(cls, tfdir, filenames, deep=True, restore_files=False):
"""Remove linked files and .terraform folder at instance deletion."""
def remove_readonly(func, path, excinfo):
_LOGGER.warning(f'Issue deleting file {path}, caused by {excinfo}')
os.chmod(path, stat.S_IWRITE)
func(path)
_LOGGER.debug('cleaning up %s %s', tfdir, filenames)
tf_path = Path(tfdir)
for filename in filenames:
(tf_path / filename).unlink(missing_ok=True)
if not deep:
return
terraform_dir = tf_path / '.terraform'
if terraform_dir.is_dir():