Logo Search packages:      
Sourcecode: cclib version File versions  Download package

def cclib::parser::logfileparser::Logfile::__init__ (   self,
  source,
  progress = None,
  loglevel = logging.INFO,
  logname = "Log",
  logstream = sys.stdout,
  fupdate = 0.05,
  cupdate = 0.002,
  datatype = ccData 
)
Initialise the Logfile object.

This should be called by a ubclass in its own __init__ method.

Inputs:
    source - a single logfile, a list of logfiles, or input stream

Definition at line 91 of file logfileparser.py.

                                       :
        """Initialise the Logfile object.

        This should be called by a ubclass in its own __init__ method.

        Inputs:
            source - a single logfile, a list of logfiles, or input stream
        """

        # Set the filename to source if it is a string or a list of filenames.
        # In the case of an input stream, set some arbitrary name and the stream.
        # Elsewise, raise an Exception.
        if isinstance(source,types.StringTypes):
            self.filename = source
            self.isstream = False
        elif isinstance(source,list) and all([isinstance(s,types.StringTypes) for s in source]):
            self.filename = source
            self.isstream = False
        elif hasattr(source, "read"):
            self.filename = "stream %s" %str(type(source))
            self.isstream = True
            self.stream = source
        else:
            raise ValueError

        # Progress indicator.
        self.progress = progress
        self.fupdate = fupdate
        self.cupdate = cupdate

        # Set up the logger.
        # Note that calling logging.getLogger() with one name always returns the same instance.
        # Presently in cclib, all parser instances of the same class use the same logger,
        #   which means that care needs to be taken not to duplicate handlers.
        self.loglevel = loglevel
        self.logname  = logname
        self.logger = logging.getLogger('%s %s' % (self.logname,self.filename))
        self.logger.setLevel(self.loglevel)
        if len(self.logger.handlers) == 0:
                handler = logging.StreamHandler(logstream)
                handler.setFormatter(logging.Formatter("[%(name)s %(levelname)s] %(message)s"))
                self.logger.addHandler(handler)

        # Periodic table of elements.
        self.table = utils.PeriodicTable()

        # This is the class that will be used in the data object returned by parse(),
        #   and should normally be ccData or a subclass.
        self.datatype = datatype


Generated by  Doxygen 1.6.0   Back to index