def parseline(self, line, lineno): __pychecker__ = 'no-argsused' n = line.split() # Everything we have is of the form 'directive argument', # so we can be really simple: if len(n) != 2: raise BadInput, "badly formatted line" # Every directive except 'listen' can only be given once, # so we can do this checking very easily. if n[0] != "listen" and self.cf.has_key(n[0]): raise BadInput, "can only give one %s directive" % \ (n[0],) # These three do no contents-checking: they just store it. if n[0] in ('rulefile', 'actionfile', 'user', 'aftermaxthreads'): self.cf[n[0]] = n[1] # I really need a better name for this. elif n[0] == 'dropipafter': self.cf[n[0]] = util.getsecs_or_raise(n[1], BadInput) elif n[0] == 'expireevery': self.cf[n[0]] = util.getsecs_or_raise(n[1], BadInput) elif n[0] == 'maxthreads': self.cf[n[0]] = util.int_or_raise(n[1], BadInput) elif n[0] == 'listen': # Listen stores host/port pairs in a list, since # we can legally accept multiple listen directives. # We insist that the port is always specified, but # the IP address can be wildcarded. r = util.gethostport(n[1]) if not r: raise BadInput, "bad argument to listen" if r[1] == '': raise BadInput, "listen requires a port" self.cf['listen'].append(r) elif n[0] == 'onfileerror': if n[1] not in ('drop', 'use-old'): raise BadInput, "unknown option for onfileerror" self.cf[n[0]] = n[1] elif n[0] == "substitutions": if n[1] not in ("off", "on"): raise BadInput, "substitutions must be off or on" self.cf[n[0]] = n[1] else: raise BadInput, "unknown config file directive "+n[0] return None
def __init__(self, name, val): self.name = name self.secsold = util.getsecs_or_raise(val, BadArg)