added is_ prefix to StagingDir bools

This commit is contained in:
Jakub Trllo 2025-01-07 15:39:57 +01:00
parent 2b1a04b5c0
commit 25f6ec241b
3 changed files with 29 additions and 9 deletions

View file

@ -915,7 +915,7 @@ class Creator(BaseCreator):
instance.transient_data.update({
"stagingDir": staging_dir_path,
"stagingDir_persistent": staging_dir_info.persistent,
"stagingDir_persistent": staging_dir_info.is_persistent,
})
self.log.info(f"Applied staging dir to instance: {staging_dir_path}")

View file

@ -716,8 +716,8 @@ def get_instance_staging_dir(instance):
os.makedirs(staging_dir_path, exist_ok=True)
instance.data.update({
"stagingDir": staging_dir_path,
"stagingDir_persistent": staging_dir_info.persistent,
"stagingDir_custom": staging_dir_info.custom
"stagingDir_persistent": staging_dir_info.is_persistent,
"stagingDir_custom": staging_dir_info.is_custom
})
return staging_dir_path

View file

@ -14,8 +14,28 @@ from .tempdir import get_temp_dir
@dataclass
class StagingDir:
directory: str
persistent: bool
custom: bool # Whether the staging dir is a custom staging dir
is_persistent: bool
# Whether the staging dir is a custom staging dir
is_custom: bool
def __setattr__(self, key, value):
if key == "persistent":
warnings.warn(
"'StagingDir.persistent' is deprecated."
" Use 'StagingDir.is_persistent' instead.",
DeprecationWarning
)
key = "is_persistent"
super().__setattr__(key, value)
@property
def persistent(self):
warnings.warn(
"'StagingDir.persistent' is deprecated."
" Use 'StagingDir.is_persistent' instead.",
DeprecationWarning
)
return self.is_persistent
def get_staging_dir_config(
@ -198,8 +218,8 @@ def get_staging_dir_info(
dir_template = staging_dir_config["template"]["directory"]
return StagingDir(
dir_template.format_strict(ctx_data),
persistent=staging_dir_config["persistence"],
custom=True
is_persistent=staging_dir_config["persistence"],
is_custom=True
)
# no config found but force an output
@ -211,8 +231,8 @@ def get_staging_dir_info(
prefix=prefix,
suffix=suffix,
),
persistent=False,
custom=False
is_persistent=False,
is_custom=False
)
return None