From 66eefc5c771ec365dd165aa42cd7e27e18fade0d Mon Sep 17 00:00:00 2001 From: "Ira W. Snyder" Date: Tue, 26 Dec 2006 15:28:28 -0800 Subject: [PATCH] [CONFIG] Update RarslaveConfig for rarslave2 Updates the RarslaveConfig class for rarslave2, removing things that were only needed in the original rarslave, and adding new things that we need. Signed-off-by: Ira W. Snyder --- RarslaveConfig.py | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/RarslaveConfig.py b/RarslaveConfig.py index a3defe5..527d976 100644 --- a/RarslaveConfig.py +++ b/RarslaveConfig.py @@ -61,6 +61,12 @@ class RarslaveConfig (object): if s == 'regular expressions': config.set(s, k, self.get_value(s, k)) + # [commands] section + config.add_section('commands') + for (s, k) in self.__defaults.keys(): + if s == 'commands': + config.set(s, k, self.get_value(s, k)) + # Try to make the ~/.config/rarslave/ directory if not os.path.isdir(os.path.split(filename)[0]): try: @@ -95,26 +101,31 @@ class RarslaveConfig (object): value = self.__get_default_val(section, key) # Convert config options to booleans for easier use - if value == 'True': - value = True + SAFE_EVAL = ['None', 'True', 'False', '-1', '0', '1', '2'] - if value == 'False': - value = False + if value in SAFE_EVAL: + value = eval (value) return value def __init__(self): self.__defaults = { ('directories', 'working_directory') : '~/downloads/usenet', + ('directories', 'extract_directory') : None, ('options', 'recursive') : True, ('options', 'check_required_programs') : False, - ('options', 'extract_with_full_path') : False, ('options', 'interactive') : False, ('options', 'output_loglevel') : 1, - ('regular expressions', 'par2_regex') : '.*\.par2$', - ('regular expressions', 'video_file_regex') : '.*\.(avi|ogm|mkv|mp4)$', - ('regular expressions', 'temp_repair_regex') : '.*\.1$', - ('regular expressions', 'remove_regex') : '^.*\.(rar|r\d\d)$' } + ('regular expressions', 'par2_regex') : '^.*\.par2$', + ('regular expressions', 'delete_regex') : + '^.*\.(par2|\d|\d\d\d|rar|r\d\d|zip)$', + ('regular expressions', 'basename_regex') : + '^(.+)\.(par2|vol\d+\+\d+|\d\d\d|part\d+|rar|zip|avi|mp4|mkv|ogm)$', + ('commands', 'unrar') : 'unrar x -o+ -- ', + ('commands', 'unzip') : 'unzip \"%s\" -d \"%s\" ', + ('commands', 'noextract') : 'mv \"%s\" \"%s\" ', + ('commands', 'par2repair') : 'par2repair -- ', + } self.__user_config = self.__read_config() -- 2.25.1