X-Git-Url: https://www.irasnyder.com/gitweb/?p=rarslave2.git;a=blobdiff_plain;f=rarslave.py;h=7c1b4c8ea12fda90eb7c9e3a346734a9d9ca3a85;hp=a27c334cfe2e14d2b159c2defbaf5657c81e1de4;hb=f66165cb39c650eb1cec0b24e07940760d602ffa;hpb=24f030f703d80f8eedc85a4c4039e81006fd20a3 diff --git a/rarslave.py b/rarslave.py index a27c334..7c1b4c8 100755 --- a/rarslave.py +++ b/rarslave.py @@ -1,8 +1,38 @@ #!/usr/bin/env python -# vim: set ts=4 sts=4 sw=4 textwidth=112 : +# vim: set ts=4 sts=4 sw=4 textwidth=92: + +""" +The main program of the rarslave project. + +This handles all of the commandline, configuration file, and option +work. It gets the environment set up for a run using the RarslaveDetector +class. +""" + +__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)" + +# rarslave.py -- a usenet autorepair and autoextract utility +# +# 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 VERSION="2.0.0" -PROGRAM="rarslave2" +PROGRAM="rarslave" import os, sys, optparse, logging import rsutil @@ -14,6 +44,10 @@ config = rsutil.globals.config # A tiny class to hold logging output until we're finished class DelayedLogger (object): + + """A small class to hold logging output until the program is finished running. + It emulates sys.stdout in the needed ways for the logging module.""" + def __init__ (self, output=sys.stdout.write): self.__messages = [] self.__output = output @@ -38,6 +72,8 @@ class DelayedLogger (object): # A tiny class used to find unique PAR2 sets class CompareSet (object): + """A small class used to find unique PAR2 sets""" + def __init__ (self, dir, p2file): self.dir = dir self.p2file = p2file @@ -52,8 +88,11 @@ class CompareSet (object): def find_all_par2_files (dir): - """Finds all par2 files in a directory""" - # NOTE: does NOT return absolute paths + """Finds all par2 files in the given directory. + + dir -- the directory in which to search for PAR2 files + + NOTE: does not return absolute paths""" if not os.path.isdir (os.path.abspath (dir)): raise ValueError # bad directory given @@ -64,7 +103,9 @@ def find_all_par2_files (dir): return rsutil.common.find_par2_files (files) def generate_all_parsets (dir): - # Generate all parsets in the given directory. + """Generate all parsets in the given directory + + dir -- the directory in which to search""" assert os.path.isdir (dir) # Directory MUST be valid @@ -100,6 +141,8 @@ def check_required_progs(): sys.exit(1) def run_options (options): + """Process all of the commandline options, doing thing such as printing the + version number, etc.""" # Fix directories options.work_dir = rsutil.common.full_abspath (options.work_dir) @@ -129,11 +172,14 @@ def run_options (options): if options.write_def_config: config.write_config (default=True) + sys.exit (0) if options.write_config: config.write_config () + sys.exit (0) def find_loglevel (options): + """Find the log level that should be printed by the logging class""" loglevel = options.verbose - options.quiet