The cleanmymac.target Module

class cleanmymac.target.DirTarget(config, update=False, verbose=False)[source]

Bases: cleanmymac.target.Target

Class encapsulating the logic to execute directory based cleanup operations. The main operation consists of identifying and removing all matching directories in a given path with the exception of the most recent version. This is an abstract class.

Warning

if pattern is not specified: all files and folders in dir will be removed

Parameters:
  • config (dict) – a configuration dictionary
  • update (bool) – perform the update before cleanup if True
  • verbose (bool) – verbose output if True
clean(**kwargs)[source]
config
describe()[source]
entries

the list of entries (pairs of path: regex pattern) to scan for cleanup. Keeps latest versions only.

Returns:a list of entries path:pattern pairs
Return type:list
update(**kwargs)[source]
update_message

message to be displayed during the update operation

Returns:the message
Return type:str
class cleanmymac.target.ShellCommandTarget(config, update=False, verbose=False)[source]

Bases: cleanmymac.target.Target

Class encapsulating general logic to execute cleanup operations based on predefined shell commands. This is an abstract class.

Parameters:
  • config (dict) – a configuration dictionary
  • update (bool) – perform the update before cleanup if True
  • verbose (bool) – verbose output if True
clean(**kwargs)[source]
clean_commands

the shell commands executed on clean. Each command is a string as expected by sarge.run()

Returns:a list of shell commands
Return type:list
config
describe()[source]
update(**kwargs)[source]
update_commands

the shell commands executed on update. Each command is a string as expected by sarge.run()

Returns:a list of shell commands
Return type:list
class cleanmymac.target.Target(config, update=False, verbose=False)[source]

Bases: object

the main cleanup Target. This is an abstract class.

Parameters:
  • config (dict) – a configuration dictionary
  • update (bool) – perform the update before cleanup if True
  • verbose (bool) – verbose output if True
clean(**kwargs)[source]

the cleanup operation

Parameters:kwargs (dict) – additional arguments
config
describe()[source]

the description of the combined update and clean operations

Returns:a string describing the steps to be undertaken
Return type:str
update(**kwargs)[source]

the update operation

Parameters:kwargs (dict) – additional arguments
class cleanmymac.target.YamlDirTarget(config, update=False, verbose=False)[source]

Bases: cleanmymac.target.DirTarget

Class encapsulating the logic to execute directory based cleanup operations. The main operation consists of identifying and removing all matching directories in a given path with the exception of the most recent version. This concrete implementation allows for the specification of entries in a YAML configuration file. See predefined builtins in cleanmymac.builtins.

Parameters:
  • config (dict) – a configuration dictionary
  • update (bool) – perform the update before cleanup if True
  • verbose (bool) – verbose output if True
clean(**kwargs)
config
describe()
entries
update(**kwargs)
update_message
class cleanmymac.target.YamlShellCommandTarget(config, update=False, verbose=False)[source]

Bases: cleanmymac.target.ShellCommandTarget

Class encapsulating logic to initialize and execute cleanup targets defined in YAML files. See predefined builtins in cleanmymac.builtins.

Parameters:
  • config (dict) – a configuration dictionary
  • update (bool) – perform the update before cleanup if True
  • verbose (bool) – verbose output if True
clean(**kwargs)
clean_commands
config
describe()
update(**kwargs)
update_commands