X-Git-Url: https://www.irasnyder.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=RarslaveDetector.py;h=798183681c0f901c93a0843d27e6a7632b6539ca;hb=063e02e2f4395d547d548051d525c0e39f060baf;hp=0895e460d51ff1fbe1ba64401712a5f50bd7db39;hpb=005129118bcc031f57c57d39ba8b05ed1842c47c;p=rarslave2.git diff --git a/RarslaveDetector.py b/RarslaveDetector.py index 0895e46..7981836 100644 --- a/RarslaveDetector.py +++ b/RarslaveDetector.py @@ -1,6 +1,33 @@ #!/usr/bin/env python # vim: set ts=4 sts=4 sw=4 textwidth=92: +""" +Class which runs each detector in the PAR2Set classes, and attempts +to run all matches on the current set. +""" + +__author__ = "Ira W. Snyder (devel@irasnyder.com)" +__copyright__ = "Copyright (c) 2006, Ira W. Snyder (devel@irasnyder.com)" +__license__ = "GNU GPL v2 (or, at your option, any later version)" + +# RarslaveDetector.py +# +# 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 rsutil.common # PAR2Set-derived types @@ -16,9 +43,11 @@ import logging class RarslaveDetector (object): - # A tuple of tuples with the following definition: - # (TYPE_NAME, DETECTION_FUNCTION, PAR2Set-derived class) + """A class to detect the type of a set, and then run the appropriate class + on the set.""" + # A tuple of tuples of the following type: + # (type_detection_function, type_working_class) TYPES = ( (PAR2Set.Join.detector, PAR2Set.Join.Join), (PAR2Set.ZIP.detector, PAR2Set.ZIP.ZIP), (PAR2Set.OldRAR.detector, PAR2Set.OldRAR.OldRAR), @@ -29,6 +58,10 @@ class RarslaveDetector (object): ) def __init__ (self, dir, p2file): + """Constructor + + dir -- the directory containing this set + p2file -- a single PAR2 file from this set""" # The real "meat" of the class self.dir = dir @@ -45,8 +78,8 @@ class RarslaveDetector (object): self.prot_matched_files = rsutil.common.parse_all_par2 (self.dir, self.p2file, self.all_p2files) def runMatchingTypes (self): - # Now tries to run every type of PAR2Set-derived class for which the detector - # detects that the class is valid. + """Run all matching PAR2Set types for which the detection function detects that + the class is valid.""" detected = False