Will validate sound settings and values, returns data packet.
495505
def _sound_settings(area, setting, value, validate_value):
        """"""
        if validate_value:
            if (setting in CONST.VALID_SOUND_SETTINGS
                    and value not in CONST.ALL_SETTING_SOUND):
                raise AbodeException(ERROR.INVALID_SETTING_VALUE,
                                     CONST.ALL_SETTING_SOUND)
            elif (setting == CONST.SETTING_ALARM_LENGTH
                  and value not in CONST.ALL_SETTING_ALARM_LENGTH):
                raise AbodeException(ERROR.INVALID_SETTING_VALUE,
                                     CONST.ALL_SETTING_ALARM_LENGTH)
            elif (setting == CONST.SETTING_FINAL_BEEPS
                  and value not in CONST.ALL_SETTING_FINAL_BEEPS):
                raise AbodeException(ERROR.INVALID_SETTING_VALUE,
                                     CONST.ALL_SETTING_FINAL_BEEPS)

        return {'area': area, setting: value}
772743
def _validate_data(data):
    
    data_keys = set(data.keys())
    extra_keys = data_keys - set(ALLOWED_KEYS)
    missing_keys = set(REQUIRED_KEYS) - data_keys

    if extra_keys:
        raise ValueError(
            'Invalid data keys {!r}'.format(', '.join(extra_keys))
        )

    if missing_keys:
        raise ValueError(
            'Missing keys {!r}'.format(', '.join(missing_keys))
        )
640295
def validate(self, protocol_version, values=None):
        """"""
        if values is None:
            values = self.values
        return self.get_schema(protocol_version)(values)
107850
function checkRFCData(data){
   var ret=null;
   var RFC_Version = data[0];
   var TPKT_Length = data.readInt16BE(2);
   var TPDU_Code = data[5]; //Data==0xF0 !!
   var LastDataUnit = data[6];//empty fragmented frame => 0=not the last package; 1=last package

   if(RFC_Version !==0x03 && TPDU_Code !== 0xf0){
      //Check if its an RFC package and a Data package
      return 'error';
   }else if((LastDataUnit >> 7) === 0 && TPKT_Length == data.length &&  data.length === 7){
      // Check if its a Fast Acknowledge package from older PLCs or  WinAC or data is too long ...
      // For example: <Buffer 03 00 00 07 02 f0 00> => data.length==7
      ret='fastACK';
   }else if((LastDataUnit >> 7) == 1 && TPKT_Length <= data.length){
      // Check if its an  FastAcknowledge package + S7Data package
      // <Buffer 03 00 00 1b 02 f0 80 32 03 00 00 00 00 00 08 00 00 00 00 f0 00 00 01 00 01 00 f0> => data.length==7+20=27
      ret=data;
   }else if((LastDataUnit >> 7) == 0  && TPKT_Length !== data.length){
      // Check if its an  FastAcknowledge package + FastAcknowledge package+ S7Data package
      // Possibly because NodeS7 or Application is too slow at this moment!
      // <Buffer 03 00 00 07 02 f0 00 03 00 00 1b 02 f0 80 32 03 00 00 00 00 00 08 00 00 00 00 f0 00 00 01 00 01 00 f0>  => data.length==7+7+20=34
      ret=data.slice(7, data.length)//Cut off the first Fast Acknowledge Packet
   }else{
      ret='error';
   }
   return ret;
}
1264764
def validate(self):
        """"""
        if not (isinstance(self.start_class, set) and
                all(isinstance(x, six.string_types) for x in self.start_class)):
            raise TypeError(u'Expected set of string start_class, got: {} {}'.format(
                type(self.start_class).__name__, self.start_class))

        for cls in self.start_class:
            validate_safe_string(cls)
63916
def validate_appname_or_none(option, value):
    """"""
    if value is None:
        return value
    validate_string(option, value)
    # We need length in bytes, so encode utf8 first.
    if len(value.encode('utf-8')) > 128:
        raise ValueError("%s must be <= 128 bytes" % (option,))
    return value
1299965
def isValid(folder, epoch=0):
    
    # Validate by checking for the training 'silence.pkl' on the given epoch
    # This file is unique to our pre-processed dataset generated by 'process_dataset.py'
    return os.path.exists(os.path.join(folder, str(epoch), "train", "silence.pkl"))
994654
def _validated(self, data):
        """"""
        for sub in self.schemas:
            data = sub(data)
        return data
1142275
def _payload(self):
        """"""
        return self.tcp or self.udp or self.icmpv4 or self.icmpv6
1010370
def isAudio(self):
        
        val=False
        if self.__dict__['codec_type']:
            if str(self.__dict__['codec_type']) == 'audio':
                val=True
        return val
712350
def validate(config):
    '''
    
    '''

    VALID_ITEMS = [
        'type', 'bytes_sent', 'bytes_recv', 'packets_sent',
        'packets_recv', 'errin', 'errout', 'dropin',
        'dropout'
    ]

    # Configuration for load beacon should be a list of dicts
    if not isinstance(config, list):
        return False, ('Configuration for network_info beacon must be a list.')
    else:

        _config = {}
        list(map(_config.update, config))

        for item in _config.get('interfaces', {}):
            if not isinstance(_config['interfaces'][item], dict):
                return False, ('Configuration for network_info beacon must '
                               'be a list of dictionaries.')
            else:
                if not any(j in VALID_ITEMS for j in _config['interfaces'][item]):
                    return False, ('Invalid configuration item in '
                                   'Beacon configuration.')
    return True, 'Valid beacon configuration'
1369939
function (result) {
            if (result.stat('audioInputLevel')) {
              currentStats.audioSentPackets = Number(result.stat('packetsSent'));
              currentStats.audioSentPacketsLost = Number(result.stat('packetsLost'));
              currentStats.audioSentBytes =  Number(result.stat('bytesSent'));
              currentStats.audioCodec = result.stat('googCodecName');
              currentStats.audioRtt = Number(result.stat('googRtt'));
            } else if (result.stat('audioOutputLevel')) {
              currentStats.audioRecvPackets = Number(result.stat('packetsReceived'));
              currentStats.audioRecvPacketsLost = Number(result.stat('packetsLost'));
              currentStats.audioRecvBytes =  Number(result.stat('bytesReceived'));
              currentStats.audioCodec = result.stat('googCodecName');
            }
          }
132361
function loadSample(url, doAfterLoading) {
    var fetchSound = new XMLHttpRequest(); // Load the Sound with XMLHttpRequest
    fetchSound.open("GET", url, true); // Path to Audio File
    fetchSound.responseType = "arraybuffer"; // Read as Binary Data
    fetchSound.onload = function() {
        context.decodeAudioData(fetchSound.response, doAfterLoading);
    }
    fetchSound.send();
}
858928
def validate(self):
        """"""
        if not (isinstance(self.target_class, set) and
                all(isinstance(x, six.string_types) for x in self.target_class)):
            raise TypeError(u'Expected set of string target_class, got: {} {}'.format(
                type(self.target_class).__name__, self.target_class))

        for cls in self.target_class:
            validate_safe_string(cls)
1294164
def validate_noise_probabilities(noise_parameter):
    
    if not noise_parameter:
        return
    if not isinstance(noise_parameter, list):
        raise TypeError("noise_parameter must be a list")
    if any([not isinstance(value, float) for value in noise_parameter]):
        raise TypeError("noise_parameter values should all be floats")
    if len(noise_parameter) != 3:
        raise ValueError("noise_parameter lists must be of length 3")
    if sum(noise_parameter) > 1 or sum(noise_parameter) < 0:
        raise ValueError("sum of entries in noise_parameter must be between 0 and 1 (inclusive)")
    if any([value < 0 for value in noise_parameter]):
        raise ValueError("noise_parameter values should all be non-negative")
321452
private boolean checkSupportedAudio() {
        AudioHeader header = audioFile.getAudioHeader();
        bitrate = header.getBitRateAsNumber();
        sampleRate = header.getSampleRateAsNumber();
        channels = header.getChannels();
        if (header.getChannels().toLowerCase().contains("stereo")) {
            channels = "2";
        }

        if (header instanceof MP3AudioHeader) {
            duration = ((MP3AudioHeader) header).getPreciseTrackLength();
        } else if (header instanceof Mp4AudioHeader) {
            duration = (double) ((Mp4AudioHeader) header).getPreciseLength();
        } else {
            duration = (double) header.getTrackLength();
        }

        // generic frames
        Tag tag = audioFile.getTag();
        artist = tag.getFirst(FieldKey.ARTIST);
        album = tag.getFirst(FieldKey.ALBUM);
        title = tag.getFirst(FieldKey.TITLE);
        comment = tag.getFirst(FieldKey.COMMENT);
        year = tag.getFirst(FieldKey.YEAR);
        track = tag.getFirst(FieldKey.TRACK);
        genre = tag.getFirst(FieldKey.GENRE);

        artwork = new ArrayList<>();
        for (Artwork a : tag.getArtworkList()) {
            AudioMetadataArtwork ama = new AudioMetadataArtwork();
            ama.setMimeType(a.getMimeType());
            if (a.getPictureType() >= 0) {
                ama.setType(a.getPictureType());
            }
            ama.setData(a.getBinaryData());

            artwork.add(ama);
        }

        return true;
    }
1023693
def getAmbientThreshold(self):
    """"""
    command = '$GO'
    threshold = self.sendCommand(command)
    if threshold[0] == 'NK':
      return 0
    else:
      return float(threshold[1])/10