Changeset 764 for pykota

Show
Ignore:
Timestamp:
02/08/03 23:09:52 (22 years ago)
Author:
jalet
Message:

Name check method moved here

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/tool.py

    r742 r764  
    1515# 
    1616# $Log$ 
     17# Revision 1.15  2003/02/08 22:09:52  jalet 
     18# Name check method moved here 
     19# 
    1720# Revision 1.14  2003/02/07 10:42:45  jalet 
    1821# Indentation problem 
     
    164167        return (parsed, args) 
    165168     
     169    def isValidName(self, name) : 
     170        """Checks if a user or printer name is valid.""" 
     171        # unfortunately Python 2.1 string modules doesn't define ascii_letters... 
     172        asciiletters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' 
     173        digits = '0123456789' 
     174        if name[0] in asciiletters : 
     175            validchars = asciiletters + digits + "-_" 
     176            for c in name[1:] : 
     177                if c not in validchars : 
     178                    return 0 
     179            return 1         
     180        return 0 
     181         
    166182    def sendMessage(self, touser, fullmessage) : 
    167183        """Sends an email message containing headers to some user."""