return a tuple for proper messages
179326
static List[] findTypos(Collection<String> fields, Mapping mapping) {
        Set<String> keys = mapping.flatten().keySet();

        // find missing
        List<String> missing = new ArrayList<String>(fields.size());

        for (String field : fields) {
            if (!keys.contains(field) && !isBuiltIn(field)) {
                missing.add(field);
            }
        }
        if (missing.isEmpty()) {
            return null;
        }
        Map<String, String> unwrapped = new LinkedHashMap<String, String>();
        // find similar
        for (String key : keys) {
            int match = key.lastIndexOf(".");
            if (match > 0) {
                String leafField = key.substring(match + 1);
                // leaf fields are secondary to top-level ones (in case of overwrite, the top level ones win)
                if (!unwrapped.containsKey(leafField)) {
                    unwrapped.put(leafField, key);
                }
            }
            unwrapped.put(key, key);
        }

        List<String> typos = new ArrayList<String>();

        Set<String> similar = unwrapped.keySet();
        for (String string : missing) {
            List<String> matches = StringUtils.findSimiliar(string, similar);
            for (String match : matches) {
                // get actual field
                typos.add(unwrapped.get(match));
            }
        }

        return new List[] { missing, typos };
    }
9452
def __make_innermsg(resource, rtype, ref, action=None, payload=None, limit=None):
        
        if action is not None and not isinstance(action, (tuple, list)):
            raise TypeError('action must be None/tuple/list')
        p = {M_RESOURCE: resource,
             M_TYPE: int(rtype),
             M_CLIENTREF: ref,
             # Ensure action path consists only of strings
             M_ACTION: tuple(u(element) for element in action) if action else None,
             M_PAYLOAD: payload}
        if limit is not None:  # Note: fmtted like "0/15" where 0 = offset, 15 = limit
            p[M_RANGE] = limit
        return p
825306
def get_message_data(msg, key):
    ''''''
    data = msg
    paths = key.split('.')
    for i in paths:
        data = getattr(data, i)
    return data
1187249
def incoming_messages(self) -> t.List[t.Tuple[float, bytes]]:
        
        approximate_messages = self._receive_buffer.qsize()
        messages = []
        for _ in range(approximate_messages):
            try:
                messages.append(self._receive_buffer.get_nowait())
            except queue.Empty:
                break
        return messages
434585
def get_valid_fns(self) -> Tuple[List[str], List[str]]:
        
        return self.prefixes_to_fns(self.valid_prefixes)
354087
def get_message(self, more_content):
        '''
        
        '''
        return {
            'status': self.status,
            'content': self.body,
            'headers': self._parse_headers(),
            'more_content': more_content
        }
989246
def build_message(self):
        '''
        '''
        if self._text is None:
            raise InvalidPayloadError('text is required')

        message = {
            'text': self._text,
            'markdown': self._markdown
        }

        if self._channel != Incoming.DEFAULT_CHANNEL:
            message['channel'] = self._channel

        if self._attachments:
            message['attachments'] = []
            for attachment in self._attachments:
                if 'title' not in attachment and 'text' not in attachment:
                    raise InvalidPayloadError('title or text is required')
                message['attachments'].append(attachment)

        return message
964647
def str2listtuple(self, string_message):
        ""

        if type(string_message).__name__ not in ('str', 'unicode'):
            raise TypeError("Must provide a string or unicode")

        if not string_message.endswith('\n'):
            string_message += "\n"

        tpl_list = []
        for line in string_message.split('\n'):
            line = line.strip()
            if not line:
                continue
            path, metric, timestamp = (None, None, None)
            try:
                (path, metric, timestamp) = line.split()
            except ValueError:
                raise ValueError(
                    "message must contain - metric_name, value and timestamp '%s'"
                    % line)
            try:
                timestamp = float(timestamp)
            except ValueError:
                raise ValueError("Timestamp must be float or int")

            tpl_list.append((path, (timestamp, metric)))

        if len(tpl_list) == 0:
            raise GraphiteSendException("No messages to send")

        payload = pickle.dumps(tpl_list)
        header = struct.pack("!L", len(payload))
        message = header + payload

        return message
307841
def get_message(self, level, alert, value, **kwargs):
        
        target, ntype = kwargs.get('target'), kwargs.get('ntype')

        msg_type = 'telegram' if ntype == 'graphite' else 'short'
        tmpl = TEMPLATES[ntype][msg_type]
        generated = tmpl.generate(
            level=level, reactor=self.reactor, alert=alert,
            value=value, target=target,)
        return generated.decode().strip()
280991
def to_string(self, metadata=False):
        """"""
        return "\n".join(rec.get_message(metadata=metadata) for rec in self)
401468
def prepare(data):
    """"""
    message = data.get("message")
    sha = data.get("sha")
    tree = data.get("tree")
    tree_sha = tree.get("sha")
    return {"message": message, "sha": sha, "tree": {"sha": tree_sha}}
83145
def visit_tuple(self, node):
        """"""
        if len(node.elts) == 1:
            return "(%s, )" % node.elts[0].accept(self)
        return "(%s)" % ", ".join(child.accept(self) for child in node.elts)
448752
def _collapseMsg(self, msg):
        
        retval = {}
        for logname in msg:
            data = u""
            for m in msg[logname]:
                m = bytes2unicode(m, self.builder.unicode_encoding)
                data += m
            if isinstance(logname, tuple) and logname[0] == 'log':
                retval['log'] = (logname[1], data)
            else:
                retval[logname] = data
        return retval
215737
def serialize_message(self, message: SegmentSequence) -> bytes:
        """"""
        if isinstance(message, FinTS3Segment):
            message = SegmentSequence([message])
        if isinstance(message, (list, tuple, Iterable)):
            message = SegmentSequence(list(message))

        result = []

        for segment in message.segments:
            result.append(self.serialize_segment(segment))

        return self.implode_segments(result)
709738
def get_message(self, metadata=False, asctime=True):
        
        msg = self.msg if is_string(self.msg) else str(self.msg)
        if self.args:
            try:
                msg = msg % self.args
            except:
                msg += str(self.args)

        if asctime: msg = "[" + self.asctime + "] " + msg

        # Add metadata
        if metadata:
            msg += "\nCalled by %s at %s:%s\n" % (self.func_name, self.pathname, self.lineno)

        return msg
1154369
def args_as_tuple(self):
        """"""
        result = ("body", )
        result = result + (
            self.arguments["body-transform"], self.arguments["match-type"])
        if self.arguments["key-list"].startswith("["):
            result = result + tuple(
                tools.to_list(self.arguments["key-list"]))
        else:
            result = result + (self.arguments["key-list"].strip('"'),)
        return result
1198437
def ensure_a_list(data):
    """"""
    if not data:
        return []
    if isinstance(data, (list, tuple, set)):
        return list(data)
    if isinstance(data, str):
        data = trimmed_split(data)  # settings.toml,other.yaml
        return data
    return [data]