def parse_gntp(data, password=None, debug=False):
 match = re.match('GNTP/(?P<version>\\d+\\.\\d+) (?P<messagetype>REGISTER|NOTIFY|SUBSCRIBE|\\-OK|\\-ERROR)', data, re.IGNORECASE)
 if (not match):
  if debug:
   print '----'
   print self.data
   print '----'
  raise ParseError('INVALID_GNTP_INFO')
 info = match.groupdict()
 if (info['messagetype'] == 'REGISTER'):
  return GNTPRegister(data, password=password)
 elif (info['messagetype'] == 'NOTIFY'):
  return GNTPNotice(data, password=password)
 elif (info['messagetype'] == 'SUBSCRIBE'):
  return GNTPSubscribe(data, password=password)
 elif (info['messagetype'] == '-OK'):
  return GNTPOK(data)
 elif (info['messagetype'] == '-ERROR'):
  return GNTPError(data)
 if debug:
  print info
 raise ParseError('INVALID_GNTP_MESSAGE')

def parse_gntp ( data , password = None , debug = False ) : match = re . match ( 'GNTP/(?P<version>\\d+\\.\\d+) (?P<messagetype>REGISTER|NOTIFY|SUBSCRIBE|\\-OK|\\-ERROR)' , data , re . IGNORECASE ) if ( not match ) : if debug : print '----' print self . data print '----' raise ParseError ( 'INVALID_GNTP_INFO' ) info = match . groupdict ( ) if ( info [ 'messagetype' ] == 'REGISTER' ) : return GNTPRegister ( data , password = password ) elif ( info [ 'messagetype' ] == 'NOTIFY' ) : return GNTPNotice ( data , password = password ) elif ( info [ 'messagetype' ] == 'SUBSCRIBE' ) : return GNTPSubscribe ( data , password = password ) elif ( info [ 'messagetype' ] == '-OK' ) : return GNTPOK ( data ) elif ( info [ 'messagetype' ] == '-ERROR' ) : return GNTPError ( data ) if debug : print info raise ParseError ( 'INVALID_GNTP_MESSAGE' )
attempt to parse a message as a gntp message .