Migrate all PAR2Set-derived classes to the package notation
authorIra W. Snyder <devel@irasnyder.com>
Mon, 1 Jan 2007 23:15:38 +0000 (15:15 -0800)
committerIra W. Snyder <devel@irasnyder.com>
Mon, 1 Jan 2007 23:15:38 +0000 (15:15 -0800)
This package migrates all of the PAR2Set-derived classes to the new PAR2Set
package notation.

Signed-off-by: Ira W. Snyder <devel@irasnyder.com>
12 files changed:
PAR2Set/Base.py
PAR2Set/ExtractFirstBase.py
PAR2Set/ExtractFirstNewRAR.py
PAR2Set/ExtractFirstOldRAR.py
PAR2Set/Join.py
PAR2Set/NewRAR.py
PAR2Set/OldRAR.py
PAR2Set/ZIP.py
PAR2Set/__init__.py
RarslaveDetector.py
RarslaveGlobals.py
rarslave.py

index e58cc16..012c01a 100644 (file)
@@ -2,7 +2,6 @@
 # vim: set ts=4 sts=4 sw=4 textwidth=92:
 
 from RarslaveCommon import *
-import RarslaveLogger
 import Par2Parser
 
 import re
@@ -28,7 +27,7 @@ import logging
 # extraction_function ()
 #
 
-class PAR2Set (object):
+class Base (object):
 
        # Instance Variables
        # ==========================================================================
index dbd1749..7385c6f 100644 (file)
@@ -2,7 +2,7 @@
 # vim: set ts=4 sts=4 sw=4 textwidth=92:
 
 import logging
-import PAR2Set
+import PAR2Set.Base
 from RarslaveCommon import *
 
 #
@@ -21,7 +21,7 @@ from RarslaveCommon import *
 # (and other) files.
 #
 
-class PAR2Set_EXTRACTFIRST (PAR2Set.PAR2Set):
+class ExtractFirstBase (PAR2Set.Base.Base):
 
        def runAll (self):
 
index 6b90591..f646c89 100644 (file)
@@ -1,8 +1,8 @@
 #!/usr/bin/env python
 # vim: set ts=4 sts=4 sw=4 textwidth=92:
 
-import PAR2Set_NEWRAR
-import PAR2Set_EXTRACTFIRST
+import PAR2Set.ExtractFirstBase
+import PAR2Set.NewRAR
 from RarslaveCommon import *
 
 #
@@ -26,13 +26,13 @@ from RarslaveCommon import *
 # with the PAR2 file itself.
 #
 
-def detect_EF_NEWRAR (name_files, prot_files):
+def detector (name_files, prot_files):
        return has_a_match ('^.*\.part0*1\.rar$', name_files) \
                        and not has_a_match ('^.*\.part0*1\.rar$', prot_files)
 
 
-class PAR2Set_EF_NEWRAR (PAR2Set_EXTRACTFIRST.PAR2Set_EXTRACTFIRST,
-                                                       PAR2Set_NEWRAR.PAR2Set_NEWRAR):
+class ExtractFirstNewRAR (PAR2Set.ExtractFirstBase.ExtractFirstBase, \
+               PAR2Set.NewRAR.NewRAR):
 
        def __repr__ (self):
                return 'EXTRACTFIRST NEWRAR'
index 9363ca7..ae2b1f2 100644 (file)
@@ -1,8 +1,8 @@
 #!/usr/bin/env python
 # vim: set ts=4 sts=4 sw=4 textwidth=92:
 
-import PAR2Set_OLDRAR
-import PAR2Set_EXTRACTFIRST
+import PAR2Set.ExtractFirstBase
+import PAR2Set.OldRAR
 from RarslaveCommon import *
 
 #
@@ -26,13 +26,13 @@ from RarslaveCommon import *
 # with the PAR2 file itself.
 #
 
-def detect_EF_OLDRAR (name_files, prot_files):
+def detector (name_files, prot_files):
        return has_a_match ('^.*\.r00$', name_files) \
                        and not has_a_match ('^.*\.r00$', prot_files)
 
 
-class PAR2Set_EF_OLDRAR (PAR2Set_EXTRACTFIRST.PAR2Set_EXTRACTFIRST,
-                                                       PAR2Set_OLDRAR.PAR2Set_OLDRAR):
+class ExtractFirstOldRAR (PAR2Set.ExtractFirstBase.ExtractFirstBase, \
+               PAR2Set.OldRAR.OldRAR):
 
        def __repr__ (self):
                return 'EXTRACTFIRST OLDRAR'
index bf0dc56..c2b055f 100644 (file)
@@ -2,7 +2,7 @@
 # vim: set ts=4 sts=4 sw=4 textwidth=92:
 
 import logging
-import PAR2Set
+import PAR2Set.Base
 from RarslaveCommon import *
 
 #
@@ -20,12 +20,12 @@ from RarslaveCommon import *
 # work where the PAR2 files are protecting the .001, etc files directly.
 #
 
-def detect_JOIN (name_files, prot_files):
+def detector (name_files, prot_files):
        return has_a_match ('^.*\.\d\d\d$', name_files) \
                        and not has_a_match ('^.*\.\d\d\d$', prot_files)
 
 
-class PAR2Set_JOIN (PAR2Set.PAR2Set):
+class Join (PAR2Set.Base.Base):
 
        def __repr__ (self):
                return 'JOIN'
index 763c025..f6702c9 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 # vim: set ts=4 sts=4 sw=4 textwidth=92:
 
-import PAR2Set
+import PAR2Set.Base
 from RarslaveCommon import *
 
 #
@@ -25,11 +25,11 @@ from RarslaveCommon import *
 # with the PAR2 file itself.
 #
 
-def detect_NEWRAR (name_files, prot_files):
+def detector (name_files, prot_files):
        return has_a_match ('^.*\.part0*1\.rar$', prot_files)
 
 
-class PAR2Set_NEWRAR (PAR2Set.PAR2Set):
+class NewRAR (PAR2Set.Base.Base):
 
        def __repr__ (self):
                return 'NEWRAR'
index 5a099fe..9c89069 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 # vim: set ts=4 sts=4 sw=4 textwidth=92:
 
-import PAR2Set
+import PAR2Set.Base
 from RarslaveCommon import *
 
 #
@@ -25,11 +25,11 @@ from RarslaveCommon import *
 # with the PAR2 file itself.
 #
 
-def detect_OLDRAR (name_files, prot_files):
+def detector (name_files, prot_files):
        return has_a_match ('^.*\.r00$', prot_files)
 
 
-class PAR2Set_OLDRAR (PAR2Set.PAR2Set):
+class OldRAR (PAR2Set.Base.Base):
 
        def __repr__ (self):
                return 'OLDRAR'
index 01b19f7..f7ddc54 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 # vim: set ts=4 sts=4 sw=4 textwidth=92:
 
-import PAR2Set
+import PAR2Set.Base
 from RarslaveCommon import *
 
 #
@@ -17,12 +17,12 @@ from RarslaveCommon import *
 # Where the PAR2 files protect a file named X.zip and/or ABC.zip.
 #
 
-def detect_ZIP (name_files, prot_files):
+def detector (name_files, prot_files):
        all_files = no_duplicates (name_files + prot_files)
        return has_a_match ('^.*\.zip$', all_files)
 
 
-class PAR2Set_ZIP (PAR2Set.PAR2Set):
+class ZIP (PAR2Set.Base.Base):
 
        def __repr__ (self):
                return 'ZIP'
index ef95396..f42d2ad 100644 (file)
@@ -7,6 +7,15 @@ __license__   = "GNU GPL v2 (or, at your option, any later version)"
 
 # Module Description Goes Here
 
+import Base
+import ExtractFirstBase
+import ExtractFirstNewRAR
+import ExtractFirstOldRAR
+import Join
+import NewRAR
+import OldRAR
+import ZIP
+
 __all__ = ['Base', 'ExtractFirstBase', 'ExtractFirstNewRAR', 'ExtractFirstOldRAR', 'Join',
                'NewRAR', 'OldRAR', 'ZIP']
 
index 9f14261..0339336 100644 (file)
@@ -4,12 +4,12 @@
 from RarslaveCommon import *
 
 # PAR2Set-derived types
-import PAR2Set_JOIN
-import PAR2Set_ZIP
-import PAR2Set_OLDRAR
-import PAR2Set_NEWRAR
-import PAR2Set_EF_OLDRAR
-import PAR2Set_EF_NEWRAR
+import PAR2Set.Join
+import PAR2Set.ZIP
+import PAR2Set.OldRAR
+import PAR2Set.NewRAR
+import PAR2Set.ExtractFirstOldRAR
+import PAR2Set.ExtractFirstNewRAR
 
 import logging
 
@@ -18,12 +18,12 @@ class RarslaveDetector (object):
        # A tuple of tuples with the following definition:
        # (TYPE_NAME, DETECTION_FUNCTION, PAR2Set-derived class)
 
-       TYPES = (       (PAR2Set_JOIN.detect_JOIN, PAR2Set_JOIN.PAR2Set_JOIN),
-                               (PAR2Set_ZIP.detect_ZIP, PAR2Set_ZIP.PAR2Set_ZIP),
-                               (PAR2Set_OLDRAR.detect_OLDRAR, PAR2Set_OLDRAR.PAR2Set_OLDRAR),
-                               (PAR2Set_NEWRAR.detect_NEWRAR, PAR2Set_NEWRAR.PAR2Set_NEWRAR),
-                               (PAR2Set_EF_OLDRAR.detect_EF_OLDRAR, PAR2Set_EF_OLDRAR.PAR2Set_EF_OLDRAR),
-                               (PAR2Set_EF_NEWRAR.detect_EF_NEWRAR, PAR2Set_EF_NEWRAR.PAR2Set_EF_NEWRAR),
+       TYPES = (       (PAR2Set.Join.detector,   PAR2Set.Join.Join),
+                               (PAR2Set.ZIP.detector,    PAR2Set.ZIP.ZIP),
+                               (PAR2Set.OldRAR.detector, PAR2Set.OldRAR.OldRAR),
+                               (PAR2Set.NewRAR.detector, PAR2Set.NewRAR.NewRAR),
+                               (PAR2Set.ExtractFirstOldRAR.detector, PAR2Set.ExtractFirstOldRAR.ExtractFirstOldRAR),
+                               (PAR2Set.ExtractFirstNewRAR.detector, PAR2Set.ExtractFirstNewRAR.ExtractFirstNewRAR),
                        )
 
        def __init__ (self, dir, p2file):
index 32a4aeb..0ecc0f0 100644 (file)
@@ -1,12 +1,11 @@
 #!/usr/bin/env python
 # vim: set ts=4 sts=4 sw=4 textwidth=92:
 
-import RarslaveLogger
 import RarslaveConfig
 
 # I know that this sucks majorly, but I kinda need it to keep things
-# sane in the code. I don't /want/ to have to keep passing the config,
-# options, and logger around all the time.
+# sane in the code. I don't /want/ to have to keep passing the config
+# and options around all the time.
 
 # This will hold the configuration from the configuration file. This should
 # only be used to hold statically, non-runtime alterable content.
@@ -17,7 +16,3 @@ config  = RarslaveConfig.RarslaveConfig ()
 # from the configuration file.
 options = None
 
-# This will hold the logger that will be able to log everything in all the
-# classes in rarslave.
-logger  = RarslaveLogger.RarslaveLogger ()
-
index a18e6a3..16b8c78 100644 (file)
@@ -213,7 +213,7 @@ def main ():
        # Run any special actions that are needed on these options
        run_options (options)
 
-       # Find the loglevel using the options given 
+       # Find the loglevel using the options given
        logging.getLogger().setLevel (find_loglevel (options))
 
        # Run recursively
@@ -233,7 +233,7 @@ def main ():
 
        # Print the results
        if logger.size () > 0:
-               print 'Log\n' + '=' * 80
+               print '\nLog\n' + '=' * 80
                logger.close ()
 
        # Done!