From 807fadd16633dba83c40d863a3d38a43a00f1e61 Mon Sep 17 00:00:00 2001 From: "Ira W. Snyder" Date: Mon, 1 Jan 2007 15:15:38 -0800 Subject: [PATCH] Migrate all PAR2Set-derived classes to the package notation This package migrates all of the PAR2Set-derived classes to the new PAR2Set package notation. Signed-off-by: Ira W. Snyder --- PAR2Set/Base.py | 3 +-- PAR2Set/ExtractFirstBase.py | 4 ++-- PAR2Set/ExtractFirstNewRAR.py | 10 +++++----- PAR2Set/ExtractFirstOldRAR.py | 10 +++++----- PAR2Set/Join.py | 6 +++--- PAR2Set/NewRAR.py | 6 +++--- PAR2Set/OldRAR.py | 6 +++--- PAR2Set/ZIP.py | 6 +++--- PAR2Set/__init__.py | 9 +++++++++ RarslaveDetector.py | 24 ++++++++++++------------ RarslaveGlobals.py | 9 ++------- rarslave.py | 4 ++-- 12 files changed, 50 insertions(+), 47 deletions(-) diff --git a/PAR2Set/Base.py b/PAR2Set/Base.py index e58cc16..012c01a 100644 --- a/PAR2Set/Base.py +++ b/PAR2Set/Base.py @@ -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 # ========================================================================== diff --git a/PAR2Set/ExtractFirstBase.py b/PAR2Set/ExtractFirstBase.py index dbd1749..7385c6f 100644 --- a/PAR2Set/ExtractFirstBase.py +++ b/PAR2Set/ExtractFirstBase.py @@ -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): diff --git a/PAR2Set/ExtractFirstNewRAR.py b/PAR2Set/ExtractFirstNewRAR.py index 6b90591..f646c89 100644 --- a/PAR2Set/ExtractFirstNewRAR.py +++ b/PAR2Set/ExtractFirstNewRAR.py @@ -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' diff --git a/PAR2Set/ExtractFirstOldRAR.py b/PAR2Set/ExtractFirstOldRAR.py index 9363ca7..ae2b1f2 100644 --- a/PAR2Set/ExtractFirstOldRAR.py +++ b/PAR2Set/ExtractFirstOldRAR.py @@ -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' diff --git a/PAR2Set/Join.py b/PAR2Set/Join.py index bf0dc56..c2b055f 100644 --- a/PAR2Set/Join.py +++ b/PAR2Set/Join.py @@ -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' diff --git a/PAR2Set/NewRAR.py b/PAR2Set/NewRAR.py index 763c025..f6702c9 100644 --- a/PAR2Set/NewRAR.py +++ b/PAR2Set/NewRAR.py @@ -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' diff --git a/PAR2Set/OldRAR.py b/PAR2Set/OldRAR.py index 5a099fe..9c89069 100644 --- a/PAR2Set/OldRAR.py +++ b/PAR2Set/OldRAR.py @@ -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' diff --git a/PAR2Set/ZIP.py b/PAR2Set/ZIP.py index 01b19f7..f7ddc54 100644 --- a/PAR2Set/ZIP.py +++ b/PAR2Set/ZIP.py @@ -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' diff --git a/PAR2Set/__init__.py b/PAR2Set/__init__.py index ef95396..f42d2ad 100644 --- a/PAR2Set/__init__.py +++ b/PAR2Set/__init__.py @@ -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'] diff --git a/RarslaveDetector.py b/RarslaveDetector.py index 9f14261..0339336 100644 --- a/RarslaveDetector.py +++ b/RarslaveDetector.py @@ -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): diff --git a/RarslaveGlobals.py b/RarslaveGlobals.py index 32a4aeb..0ecc0f0 100644 --- a/RarslaveGlobals.py +++ b/RarslaveGlobals.py @@ -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 () - diff --git a/rarslave.py b/rarslave.py index a18e6a3..16b8c78 100644 --- a/rarslave.py +++ b/rarslave.py @@ -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! -- 2.25.1