Show
Ignore:
Timestamp:
09/27/08 22:02:37 (16 years ago)
Author:
jerome
Message:

Removed unnecessary spaces at EOL.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/commandline.py

    r3411 r3413  
    88# the Free Software Foundation, either version 3 of the License, or 
    99# (at your option) any later version. 
    10 #  
     10# 
    1111# This program is distributed in the hope that it will be useful, 
    1212# but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1313# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1414# GNU General Public License for more details. 
    15 #  
     15# 
    1616# You should have received a copy of the GNU General Public License 
    1717# along with this program.  If not, see <http://www.gnu.org/licenses/>. 
     
    3636        loginvalidparam(opt, value, option.default) 
    3737        setattr(optionparser.values, option.dest, option.default) 
    38     else :     
    39         setattr(optionparser.values, option.dest, value) 
    40      
    41 def checkandset_savetoner(option, opt, value, optionparser) :     
     38    else : 
     39        setattr(optionparser.values, option.dest, value) 
     40 
     41def checkandset_savetoner(option, opt, value, optionparser) : 
    4242    """Checks and sets the save toner value.""" 
    4343    if (value < 0.0) or (value > 99.0) : 
     
    4545                        _("Allowed range is (0..99)")) 
    4646        setattr(optionparser.values, option.dest, option.default) 
    47     else :     
    48         setattr(optionparser.values, option.dest, value) 
    49          
    50 def checkandset_positiveint(option, opt, value, optionparser) :     
     47    else : 
     48        setattr(optionparser.values, option.dest, value) 
     49 
     50def checkandset_positiveint(option, opt, value, optionparser) : 
    5151    """Checks if an option argument is a positive integer and validates the option if it is the case.""" 
    5252    if not (value >= 0) : 
     
    5454                        _("Value must be positive")) 
    5555        setattr(optionparser.values, option.dest, option.default) 
    56     else :     
    57         setattr(optionparser.values, option.dest, value) 
    58          
    59 def checkandset_positivefloat(option, opt, value, optionparser) :     
     56    else : 
     57        setattr(optionparser.values, option.dest, value) 
     58 
     59def checkandset_positivefloat(option, opt, value, optionparser) : 
    6060    """Checks if an option argument is a positive float and validates the option if it is the case.""" 
    6161    if not (value >= 0.0) : 
     
    6363                        _("Value must be positive")) 
    6464        setattr(optionparser.values, option.dest, option.default) 
    65     else :     
    66         setattr(optionparser.values, option.dest, value) 
    67  
    68 def checkandset_percent(option, opt, value, optionparser) :     
     65    else : 
     66        setattr(optionparser.values, option.dest, value) 
     67 
     68def checkandset_percent(option, opt, value, optionparser) : 
    6969    """Checks if an option argument is comprised between 0.0 included and 100.0 not included, and validates the option if it is the case.""" 
    7070    if not (0.0 <= value < 100.0) : 
     
    7272                        _("Value must be comprised between 0.0 included and 100.0 not included")) 
    7373        setattr(optionparser.values, option.dest, option.default) 
    74     else :     
    75         setattr(optionparser.values, option.dest, value) 
    76  
    77 def load_arguments_file(option, opt, value, optionparser) :     
     74    else : 
     75        setattr(optionparser.values, option.dest, value) 
     76 
     77def load_arguments_file(option, opt, value, optionparser) : 
    7878    """Loads arguments from a file, one per line.""" 
    7979    setattr(optionparser.values, option.dest, value) 
     
    8989            if argi.startswith('"') and argi.endswith('"') : 
    9090                arguments[i] = argi[1:-1] 
    91         arguments.reverse()         
     91        arguments.reverse() 
    9292        for arg in arguments : 
    93             optionparser.rargs.insert(0, arg)         
     93            optionparser.rargs.insert(0, arg) 
    9494 
    9595class PyKotaOptionParser(optparse.OptionParser) : 
     
    9797    This class to define additional methods, and different help 
    9898    formatting, from the traditional OptionParser. 
    99     """    
     99    """ 
    100100    def __init__(self, *args, **kwargs) : 
    101101        """ 
     
    110110        self.remove_version_and_help() 
    111111        self.add_generic_options() 
    112          
     112 
    113113    def format_help(self, formatter=None) : 
    114114        """ 
     
    124124        result.append(self.format_copyright()) 
    125125        return "".join(result) 
    126              
    127     #     
    128     # Below are PyKota specific additions     
     126 
     127    # 
     128    # Below are PyKota specific additions 
    129129    # 
    130130    def format_filterexpressions(self, formatter=None) : 
     
    132132        if formatter is None : 
    133133            formatter = self.formatter 
    134         result = []     
     134        result = [] 
    135135        if self.filterexpressions : 
    136136            result.append(formatter.format_heading(_("filtering expressions"))) 
     
    139139            result.append("\n") 
    140140            result.append(formatter.format_heading(_("allowed keys for now"))) 
    141             formatter.indent()  
     141            formatter.indent() 
    142142            for (expression, explanation) in self.filterexpressions : 
    143143                result.append(formatter.format_description("%s : %s" % (expression, explanation))) 
    144             formatter.dedent()     
     144            formatter.dedent() 
    145145            result.append("\n") 
    146146            result.append(formatter.format_heading(_("formatting of dates with the 'start' and 'end' filtering keys"))) 
     
    156156            result.append(formatter.format_description(_("tomorrow[+-N] : tomorrow more or less N days (e.g. : tomorrow-15)"))) 
    157157            result.append(formatter.format_description(_("now[+-N] : now more or less N days (e.g. now-15)"))) 
    158             formatter.dedent()     
     158            formatter.dedent() 
    159159            result.append("\n") 
    160160            result.append(formatter.format_description(_("'now' and 'today' are not exactly the same since 'today' represents the first or last second of the day depending on if it's used in a 'start=' or 'end=' date expression."))) 
    161161            result.append("\n") 
    162162        return "".join(result) 
    163          
     163 
    164164    def format_examples(self, formatter=None) : 
    165165        """Formats examples our way.""" 
     
    174174                result.append(formatter.format_description(self.expand_prog_name(explanation)) + "\n") 
    175175            formatter.dedent() 
    176         return "".join(result)     
    177          
     176        return "".join(result) 
     177 
    178178    def format_copyright(self, formatter=None) : 
    179179        """Formats copyright message our way.""" 
    180180        if formatter is None : 
    181181            formatter = self.formatter 
    182         result = []     
     182        result = [] 
    183183        result.append(formatter.format_heading(_("licensing terms"))) 
    184184        formatter.indent() 
     
    188188        for part in version.__gplblurb__.split("\n\n") : 
    189189            result.append(formatter.format_description(part) + "\n") 
    190         formatter.dedent()     
    191         return "".join(result) 
    192          
    193     def add_filterexpression(self, expression, doc) :     
     190        formatter.dedent() 
     191        return "".join(result) 
     192 
     193    def add_filterexpression(self, expression, doc) : 
    194194        """Adds a filtering expression.""" 
    195195        self.filterexpressions.append((expression, doc)) 
    196          
    197     def add_example(self, command, doc) :     
     196 
     197    def add_example(self, command, doc) : 
    198198        """Adds an usage example.""" 
    199199        self.examples.append(("%prog " + command, doc)) 
    200          
    201     def remove_version_and_help(self) :    
     200 
     201    def remove_version_and_help(self) : 
    202202        """Removes the default definitions for options version and help.""" 
    203203        for o in ("-h", "-help", "--help", "-v", "-version", "--version") : 
    204204            try : 
    205205                self.remove_option(o) 
    206             except ValueError :      
     206            except ValueError : 
    207207                pass 
    208                  
    209     def add_generic_options(self) :     
     208 
     209    def add_generic_options(self) : 
    210210        """Adds options which are common to all PyKota command line tools.""" 
    211211        self.add_option("-h", "--help",