X-Git-Url: https://www.irasnyder.com/gitweb/?p=rarslave2.git;a=blobdiff_plain;f=RarslaveConfig.py;h=42941d76d754168396539ddf83d5472935eaa353;hp=a3defe50caafa4da2ee7e9cb7c2e27caecc9c56f;hb=d8ef527e246184551ce125e6b7963d40a1c3b97a;hpb=16584b7fab23c01c2c48eda9efad513dc4addcec diff --git a/RarslaveConfig.py b/RarslaveConfig.py index a3defe5..42941d7 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: @@ -94,27 +100,36 @@ class RarslaveConfig (object): # into the code, so DON'T DO IT value = self.__get_default_val(section, key) - # Convert config options to booleans for easier use - if value == 'True': - value = True + # Convert config options to native types for easier use + SAFE_EVAL = ['None', 'True', 'False', '-1', '0', '1', '2'] + + if value in SAFE_EVAL: + value = eval (value) - if value == 'False': - value = False + # Absolute-ize directories for easier use + if section == 'directories' and value != None: + value = os.path.abspath (os.path.expanduser (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()