fail2ban.server.datedetector module
***********************************

class fail2ban.server.datedetector.DateDetector

   Bases: "object"

   Manages one or more date templates to find a date within a log
   line.

   Attributes:
      "templates"
         List of template instances managed by the detector.

   -[ Methods ]-

   +------------+--------------------------------------------------------------------------------------------+
   | "addDefau  | Add Fail2Ban's default set of date templates.                                              |
   | ltTemplat  |                                                                                            |
   | e"(self)   |                                                                                            |
   +------------+--------------------------------------------------------------------------------------------+
   | "appendTe  | Add a date template to manage and use in search of dates.                                  |
   | mplate"(s  |                                                                                            |
   | elf,       |                                                                                            |
   | template)  |                                                                                            |
   +------------+--------------------------------------------------------------------------------------------+
   | "getTime"  | Attempts to return the date on a log line using templates.                                 |
   | (self,     |                                                                                            |
   | line)      |                                                                                            |
   +------------+--------------------------------------------------------------------------------------------+
   | "matchTim  | Attempts to find date on a log line using templates.                                       |
   | e"(self,   |                                                                                            |
   | line)      |                                                                                            |
   +------------+--------------------------------------------------------------------------------------------+
   | "sortTemp  | Sort the date templates by number of hits                                                  |
   | late"(sel  |                                                                                            |
   | f)         |                                                                                            |
   +------------+--------------------------------------------------------------------------------------------+

   addDefaultTemplate(self)

      Add Fail2Ban's default set of date templates.

   appendTemplate(self, template)

      Add a date template to manage and use in search of dates.

      Parameters:
         **template** : DateTemplate or str
            Can be either a *DateTemplate* instance, or a string which
            will be used as the pattern for the *DatePatternRegex*
            template. The template will then be added to the detector.

      Raises:
         ValueError
            If a template already exists with the same name.

   getTime(self, line)

      Attempts to return the date on a log line using templates.

      This uses the templates' *getDate* method in an attempt to find
      a date.

      Parameters:
         **line** : str
            Line which is searched by the date templates.

      Returns:
         float
            The Unix timestamp returned from the first successfully
            matched template.

   matchTime(self, line)

      Attempts to find date on a log line using templates.

      This uses the templates' *matchDate* method in an attempt to
      find a date. It also increments the match hit count for the
      winning template.

      Parameters:
         **line** : str
            Line which is searched by the date templates.

      Returns:
         re.MatchObject
            The regex match returned from the first successfully
            matched template.

   sortTemplate(self)

      Sort the date templates by number of hits

      Sort the template lists using the hits score. This method is not
      called in this object and thus should be called from time to
      time. This ensures the most commonly matched templates are
      checked first, improving performance of matchTime and getTime.

   property templates

      List of template instances managed by the detector.
