msg may or may not be encoded
430974
def write_right(self, msg, thread_lock=None):
        
        if self.cursesScreen:
            if thread_lock is not None:
                thread_lock.acquire()
            try:
                a_msg = msg.strip()
                self.cursesScreen.addstr(0, self.width + 5 - len(a_msg) - 1, a_msg.replace("\r", "").replace("\n", ""))
            except:
                a_msg = msg.encode('utf-8', 'replace').strip()
                self.cursesScreen.addstr(0, self.width + 5 - len(a_msg) - 1, a_msg.replace("\r", "").replace("\n", ""))
            self.cursesScreen.refresh()
            if thread_lock is not None:
                thread_lock.release()
1099648
def _ka_decode(self, msg):
        """"""
        return {'keypad_areas': [ord(x)-0x31 for x in msg[4:4+Max.KEYPADS.value]]}
31871
function checkMsg(msg, protos) {
    if (!protos || !msg) {
        console.warn('no protos or msg exist! msg : %j, protos : %j', msg, protos);
        return false;
    }

    for (const name in protos) {
        if (protos.hasOwnProperty(name)) {
            let message;
            const proto = protos[name];

            // All required element must exist
            switch (proto.option) {
            case 'required' :
                if (typeof (msg[name]) === 'undefined') {
                    console.warn('no property exist for required! name: %j, proto: %j, msg: %j', name, proto, msg);
                    return false;
                }
            case 'optional' :    // eslint-disable-line
                if (typeof (msg[name]) !== 'undefined') {
                    message = protos.__messages[proto.type] || Encoder.protos[`message ${proto.type}`];
                    if (!!message && !checkMsg(msg[name], message)) {
                        console.warn('inner proto error! name: %j, proto: %j, msg: %j', name, proto, msg);
                        return false;
                    }
                }
                break;
            case 'repeated' :
                // Check nest message in repeated elements
                message = protos.__messages[proto.type] || Encoder.protos[`message ${proto.type}`];
                if (!!msg[name] && !!message) {
                    for (let i = 0; i < msg[name].length; i++) {
                        if (!checkMsg(msg[name][i], message)) {
                            return false;
                        }
                    }
                }
                break;
            default:
                break;
            }
        }
    }

    return true;
}
212507
def __needs_encoding(self, s):
        
        if isinstance(s, basestring):
            for c in self.special:
                if c in s:
                    return True
1127149
function(a, allowNumbers, msg) {
    allowNumbers = allowNumbers || true;
    return assert((typeof a == 'string' && (isNaN(a)||allowNumbers)), msg);
  }
1340015
def _status_message_received(self, msg):
        
        if msg.cmd2 == 0x00 or msg.cmd2 == 0x01:
            self._update_subscribers(0x00)
        elif msg.cmd2 == 0x02 or msg.cmd2 == 0x03:
            self._update_subscribers(0xff)
        else:
            raise ValueError
870743
def iscomplete(rawmessage):
    """"""
    if len(rawmessage) < 2:
        return False

    if rawmessage[0] != 0x02:
        raise ValueError('message does not start with 0x02')

    messageBuffer = bytearray()
    filler = bytearray(30)
    messageBuffer.extend(rawmessage)
    messageBuffer.extend(filler)

    msg = _get_msg_class(rawmessage[1])

    if hasattr(msg, 'receivedSize') and msg.receivedSize:
        expectedSize = msg.receivedSize
    else:
        _LOGGER.error('Unable to find a receivedSize for code 0x%x',
                      rawmessage[1])
        return ValueError

    is_expected_size = False
    if len(rawmessage) >= expectedSize:
        is_expected_size = True

    return is_expected_size
230310
public boolean error(String msg) {
    output(getColorBuffer().red(msg), true, errorStream);
    return false;
  }
225612
def base64url_decode(msg):
    
    rem = len(msg) % 4
    if rem:
        msg += b'=' * (4 - rem)

    return base64.urlsafe_b64decode(msg)
729931
def __is_surrogate_escaped(self, text):
        

        try:
            text.encode('utf-8')
        except UnicodeEncodeError as e:
            if e.reason == 'surrogates not allowed':
                return True
        return False
161644
def _has_skip(self, msg):
        '''
        
        '''
        for skip in self.skips:
            if re.search(skip, msg):
                return True
        return False
87008
function sanitize (msg) {
  if (typeof msg !== 'object') return null
  if (typeof msg.value !== 'object') return null
  if (typeof msg.value.content !== 'object') return null
  if (typeof msg.value.timestamp !== 'number') return null
  if (typeof msg.value.type !== 'string') return null
  if (typeof msg.value.content.channel !== 'string') return null
  if (typeof msg.value.content.text !== 'string') return null
  return msg
}
1209616
function msg(str) {
	if (str == null) {
		return null;
	}

	for (var i = 1, len = arguments.length; i < len; ++i) {
		str = str.replace('{' + (i - 1) + '}', String(arguments[i]));
	}

	return str;
}
604660
def confirm?(msg)
      return true if options[:yes]
      unless STDOUT.isatty
        say(msg)
        return false
      end
      yes?(msg)
    end
488915
def verify(value, msg):
    
    return bool(value) and \
           converts_to_proto(value, msg) and \
           successfuly_encodes(msg) and \
           special_typechecking(value, msg)
1089745
def is_type(msg_type, msg):
        
        for prop in MessageType.FIELDS[msg_type]["must"]:
            if msg.get(prop, False) is False:
                return False
        for prop in MessageType.FIELDS[msg_type]["prohibit"]:
            if msg.get(prop, False) is not False:
                return False

        return True
359507
private void _decompressMessageData(Message msg) {
		if((msg.flags & Message.FLAGS_COMPRESSED) == 0) {
			throw new IllegalArgumentException("message data is not compressed");
		}
		Inflater decompresser = new Inflater();
		decompresser.setInput(msg.data);
		ByteArrayOutputStream bos = new ByteArrayOutputStream(msg.data.length);
		byte[] buffer = new byte[8192];
		try {
			while (!decompresser.finished()) {
				int size = decompresser.inflate(buffer);
				bos.write(buffer, 0, size);
			}
			msg.data = bos.toByteArray();
			msg.flags &= ~Message.FLAGS_COMPRESSED;
			decompresser.end();
		} catch (DataFormatException e) {
			throw new PyroException("invalid compressed data: ", e);
		}
	}