"""Clean deode file systems."""
from ..cleaning import CleanDeode
from .base import Task
[docs]
class Cleaning(Task):
"""Interface class to the cleaning."""
def __init__(self, config):
"""Construct object.
Args:
config (deode.ParsedConfig): Configuration
name (str): Name of task
"""
Task.__init__(self, config, __class__.__name__)
[docs]
def prep_clean_task(self, cleaning_type):
"""Setup clean task.
Args:
cleaning_type (str): Cleaning config section identifier
"""
defaults = self.config.get("cleaning.defaults")
choices = self.config.get(f"cleaning.{cleaning_type}").dict()
self.cleaner = CleanDeode(self.config, defaults)
self.cleaner.prep_cleaning(choices)
[docs]
def execute(self):
"""Run the cleaning."""
self.cleaner.clean()
[docs]
class PreCleaning(Cleaning):
"""Preparatory cleaning task."""
def __init__(self, config):
"""Construct object.
Args:
config (deode.ParsedConfig): Configuration
"""
Cleaning.__init__(self, config)
self.name = "PreCleaning"
self.prep_clean_task(self.name)
[docs]
class CycleCleaning(Cleaning):
"""Cycle cleaning task."""
def __init__(self, config):
"""Construct object.
Args:
config (deode.ParsedConfig): Configuration
"""
Cleaning.__init__(self, config)
self.name = "CycleCleaning"
self.prep_clean_task(self.name)
[docs]
class PostMortem(Cleaning):
"""Final cleaning task."""
def __init__(self, config):
"""Construct object.
Args:
config (deode.ParsedConfig): Configuration
"""
Cleaning.__init__(self, config)
self.name = "PostMortem"
self.prep_clean_task(self.name)