def _decode_options(packet, buff, start_idx):
 packet['options'] = {}
 idx = start_idx
 while (idx < len(buff)):
  (option, idx) = _get_string(buff, idx)
  (value, idx) = _get_string(buff, idx)
  if (option == ''):
   raise InvalidPacketException(u'Empty option')
  if (value == ''):
   raise InvalidPacketException((u'Empty value for option[%s]' % repr(option)))
  packet['options'][option] = value
 for (k, v) in packet['options'].items():
  if (k not in OPTIONS):
   raise InvalidOptionException((u'Unknown option[%s]' % repr(k)))
  try:
   if (k in ('blksize', 'timeout', 'tsize')):
    packet['options'][k] = int(v)
   else:
    packet['options'][k] = v
  except ValueError:
   raise InvalidOptionException((u'Invalid value for option %s: %s' % (repr(k), repr(v))))

def _decode_options ( packet , buff , start_idx ) : packet [ 'options' ] = { } idx = start_idx while ( idx < len ( buff ) ) : ( option , idx ) = _get_string ( buff , idx ) ( value , idx ) = _get_string ( buff , idx ) if ( option == '' ) : raise InvalidPacketException ( u'Empty option' ) if ( value == '' ) : raise InvalidPacketException ( ( u'Empty value for option[%s]' % repr ( option ) ) ) packet [ 'options' ] [ option ] = value for ( k , v ) in packet [ 'options' ] . items ( ) : if ( k not in OPTIONS ) : raise InvalidOptionException ( ( u'Unknown option[%s]' % repr ( k ) ) ) try : if ( k in ( 'blksize' , 'timeout' , 'tsize' ) ) : packet [ 'options' ] [ k ] = int ( v ) else : packet [ 'options' ] [ k ] = v except ValueError : raise InvalidOptionException ( ( u'Invalid value for option %s: %s' % ( repr ( k ) , repr ( v ) ) ) )
decodes options from a given packet buffer .