O'Reilly logo

Python 2.6 Text Processing Beginner's Guide by Jeff McNeil

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - adding basic configuration read support

In this example, we'll add some basic configuration file support into our ever-growing log-processing application. There are a few values that we've been passing on the command line that have become somewhat repetitive. Let's fix that.

  1. First, create logscan-h.py, using logscan-g.py as your starting place.
  2. Update the import statements at the top of the file to look like this:
    import time
    import string
    import sys
    from optparse import OptionParser
    from collections import defaultdict
    from ConfigParser import SafeConfigParser
    from ConfigParser import ParsingError
    
  3. Now, directly below the MaxSizeHandler class, add the following configuration parser function. Note that this is not a part of the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required