[RSUTIL] Fix directory handling
[rarslave2.git] / rsutil / config.py
index 17e87d3..bc8c58e 100644 (file)
@@ -1,12 +1,38 @@
 #!/usr/bin/env python
 # vim: set ts=4 sts=4 sw=4 textwidth=92:
 
+"""
+Module holding the config class, to be used by the rarslave project.
+"""
+
+__author__    = "Ira W. Snyder (devel@irasnyder.com)"
+__copyright__ = "Copyright (c) 2006,2007 Ira W. Snyder (devel@irasnyder.com)"
+__license__   = "GNU GPL v2 (or, at your option, any later version)"
+
+#    config.py -- configuration class for rarslave
+#
+#    Copyright (C) 2006,2007  Ira W. Snyder (devel@irasnyder.com)
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License
+#    along with this program; if not, write to the Free Software
+#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
 import os, ConfigParser
 
 class config (object):
        """A simple class to hold the default configs for the whole program"""
 
-       DEFAULT_CONFIG='~/.config/rarslave2/rarslave2.conf'
+       DEFAULT_CONFIG=os.path.join ('~','.config','rarslave2','rarslave2.conf')
 
        def __read_config(self, filename=DEFAULT_CONFIG):
                """Attempt to open and read the rarslave config file"""
@@ -114,7 +140,7 @@ class config (object):
 
        def __init__(self):
                self.__defaults = {
-                       ('directories', 'working_directory') : '~/downloads/usenet',
+                       ('directories', 'working_directory') : os.path.join ('~','downloads','usenet'),
                        ('directories', 'extract_directory') : None,
                        ('options', 'recursive') : True,
                        ('options', 'interactive') : False,
@@ -124,6 +150,8 @@ class config (object):
                                        '^.*\.(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)$',
+                       ('regular expressions', 'extractable_regex') :
+                                       '^.+\.(rar|r\d\d|\d\d\d|zip)$',
                        ('commands', 'unrar') : 'unrar x -o+ -- ',
                        ('commands', 'unzip') : 'unzip \"%s\" -d \"%s\" ',
                        ('commands', 'noextract') : 'mv \"%s\" \"%s\" ',