pytty

changeset 10:eea316209c01

Moved baud propery code to use decorators, its just cleaner.
author Arc Riley <arcriley@gmail.com>
date Wed, 10 Nov 2010 02:13:22 -0500
parents 20bd093f4b84
children 7f60883a6ecc
files src/__init__.py
diffstat 1 files changed, 13 insertions(+), 7 deletions(-) [+]
line diff
     1.1 --- a/src/__init__.py	Wed Nov 10 01:23:54 2010 -0500
     1.2 +++ b/src/__init__.py	Wed Nov 10 02:13:22 2010 -0500
     1.3 @@ -53,18 +53,24 @@
     1.4      fd = reader.fileno()
     1.5      fcntl(fd, F_SETFL, (fcntl(fd, F_GETFL) | O_NONBLOCK))
     1.6  
     1.7 +    # default to 9600 baud for now
     1.8 +    self.__baud = 9600
     1.9 +
    1.10      # initialize self with BufferedRWPair 
    1.11      super(TTY, self).__init__(reader, writer)
    1.12  
    1.13 -  baud_help = 'Baud rate can be set to any value but standard settings are 9600, 56000, and 115200'
    1.14 +  @property
    1.15 +  def baud (self) :
    1.16 +    '''Baud rate can be set to any value but standard settings are 9600, 56000, 
    1.17 +     and 115200'''
    1.18 +    return self.__baud
    1.19  
    1.20 -  def get_baud(self): return self.__baud
    1.21 +  @baud.setter
    1.22 +  def baud (self, rate) :
    1.23 +    # This needs to check to ensure the tty supports the given baudrate,
    1.24 +    # else raise an appropriate error
    1.25 +    self.__baud = rate
    1.26  
    1.27 -  def set_baud(self,rate): self.__baud = rate
    1.28 -
    1.29 -  def del_baud(self): del self.__baud
    1.30 -
    1.31 -  baud = property(get_baud,set_baud,del_baud,baud_help)
    1.32  
    1.33  # Clean up package namespace
    1.34  del(io)