aboutsummaryrefslogtreecommitdiff
blob: 5f174aea74bb1aeda3c4a7abf012872176ffc7a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Copyright 2002 Gentoo Technologies, Inc
# Distributed under the terms of the GNU General Public License v2.0
# Author Karl Trygve Kalleberg <karltk@gentoo.org>

from test import Test
import re

class TestSyntax(Test):

  def __init__(self,formatter,options):
    Test.__init__(self,formatter,options)
    self.desc = "Testing for correct syntax"
    self.re = [ re.compile("^(MD5 [a-z0-9]+ [a-zA-Z0-9_+.-]+ [0-9]+)") ]
    self.errors = []
    
  def checkLine(self, s, ln):
    for i in self.re:
      k = i.match(s)
      if not k:
        self.errors.append("Invalid line in digest\n |" + s)
        
  def report(self):
    for i in self.errors:
      self.formatter.suberr(i)

    
def getTests(formatter,options):
  return [ TestSyntax(formatter,options) ]