return formatted string for instance
483852
def format_output(instances, flag):
    """"""
    out = []
    line_format = '{0}\t{1}\t{2}\t{3}\t{4}'
    name_len = _get_max_name_len(instances) + 3
    if flag:
        line_format = '{0:<' + str(name_len) + '}{1:<16}{2:<21}{3:<16}{4:<16}'

    for i in instances:
        tag_name = get_tag_value(i.tags, 'Name')
        out.append(line_format.format(
            tag_name, i.state['Name'], i.id, i.private_ip_address, str(i.public_ip_address)))
    return out
1192800
def format(self, method, data):
        '''  '''
        if data is None:
            if method == 'GET':
                raise NotFound()
            return ''

        return self._meta.formatter.format(data)
329993
def GetFormattedField(self, event, field_name):
    
    callback_name = self._FIELD_FORMAT_CALLBACKS.get(field_name, None)
    callback_function = None
    if callback_name:
      callback_function = getattr(self, callback_name, None)

    if callback_function:
      output_value = callback_function(event)
    else:
      output_value = getattr(event, field_name, '-')

    if output_value is None:
      output_value = '-'

    elif not isinstance(output_value, py2to3.STRING_TYPES):
      output_value = '{0!s}'.format(output_value)

    return output_value
107429
def format(self, record):
        """"""
        data = record.__dict__.copy()

        data['data_id'] = DATA['id']
        data['data_location_id'] = DATA_LOCATION['id']
        data['hostname'] = socket.gethostname()

        # Get relative path, so listener can reconstruct the path to the actual code.
        data['pathname'] = os.path.relpath(data['pathname'], os.path.dirname(__file__))

        # Exception and Traceback cannot be serialized.
        data['exc_info'] = None

        # Ensure logging message is instantiated to a string.
        data['msg'] = str(data['msg'])

        return json.dumps(data)
618854
def format_strings(self, **kwargs):
    """"""
    return mutablerecords.CopyRecord(
        self, name=util.format_string(self.name, kwargs))
771407
def str(self, space=False):
    """"""
    return "%s/%s (%s)" % (str(int(self.id)).rjust(space and 4),
                           self.name.ljust(space and 50),
                           "; ".join(str(a) for a in self.args))
232785
def str(self, indent=0):
        
        tab = "%*s" % (indent * 3, "")
        result = []
        result.append("%s<%s" % (tab, self.qname()))
        result.append(self.nsdeclarations())
        for a in self.attributes:
            result.append(" %s" % (unicode(a),))
        if self.isempty():
            result.append("/>")
            return "".join(result)
        result.append(">")
        if self.hasText():
            result.append(self.text.escape())
        for c in self.children:
            result.append("\n")
            result.append(c.str(indent + 1))
        if len(self.children):
            result.append("\n%s" % (tab,))
        result.append("</%s>" % (self.qname(),))
        return "".join(result)
280861
def _format_str(format_int):
    """"""
    for dictionary in _formats, _subtypes, _endians:
        for k, v in dictionary.items():
            if v == format_int:
                return k
    else:
        return 'n/a'
1314485
def formatted(self, func):
        
        other = EscapedString.__new__(EscapedString)
        other.strings = []

        for is_literal, value in self.strings:
            if not is_literal:
                value = func(value)
            other.strings.append((is_literal, value))
        return other
1003274
def _str(obj):
    """"""
    values = []
    for name in obj._attribs:
        val = getattr(obj, name)
        if isinstance(val, str):
            val = repr(val)
        val = str(val) if len(str(val)) < 10 else "(...)"
        values.append((name, val))
    values = ", ".join("{}={}".format(k, v) for k, v in values)
    return "{}({})".format(obj.__class__.__name__, values)
757534
def one_liner_str(self):
        """"""
        assert self.less_attrs is not None, "Forgot to set attrs class variable"
        s_format = "{}={}"
        s = "; ".join([s_format.format(x, self.__getattribute__(x)) for x in self.less_attrs])
        return s
326351
def pretty_str(self, indent=0):
        
        if self.body:
            return '\n'.join(stmt.pretty_str(indent) for stmt in self.body)
        else:
            return (' ' * indent) + '[empty]'
137956
def string(self, writesize=None):
        '''
        
        '''
        if not self.finished:
            self.finished = True
            return self.content
        return ''
841510
def from_string(cls, string):
        

        # find enum value
        for attr in dir(cls):
            value = getattr(cls, attr)
            if value == string:
                return value

        # if not found, log warning and return the value passed in
        logger.warning("{} is not a valid enum value for {}.".format(string, cls.__name__))
        return string
861020
def String(length=None, **kwargs):
    """"""
    return Property(
        length=length,
        types=stringy_types,
        convert=to_string,
        **kwargs
    )
38011
def arbitrary_object_to_string(a_thing):
    """"""
    # is it None?
    if a_thing is None:
        return ''
    # is it already a string?
    if isinstance(a_thing, six.string_types):
        return a_thing
    if six.PY3 and isinstance(a_thing, six.binary_type):
        try:
            return a_thing.decode('utf-8')
        except UnicodeDecodeError:
            pass
    # does it have a to_str function?
    try:
        return a_thing.to_str()
    except (AttributeError, KeyError, TypeError):
        # AttributeError - no to_str function?
        # KeyError - DotDict has no to_str?
        # TypeError - problem converting
        # nope, no to_str function
        pass
    # is this a type proxy?
    try:
        return arbitrary_object_to_string(a_thing.a_type)
    except (AttributeError, KeyError, TypeError):
        #
        # nope, no a_type property
        pass
    # is it a built in?
    try:
        return known_mapping_type_to_str[a_thing]
    except (KeyError, TypeError):
        # nope, not a builtin
        pass
    # is it something from a loaded module?
    try:
        if a_thing.__module__ not in ('__builtin__', 'builtins', 'exceptions'):
            if a_thing.__module__ == "__main__":
                module_name = (
                    sys.modules['__main__']
                    .__file__[:-3]
                    .replace('/', '.')
                    .strip('.')
                )
            else:
                module_name = a_thing.__module__
            return "%s.%s" % (module_name, a_thing.__name__)
    except AttributeError:
        # nope, not one of these
        pass
    # maybe it has a __name__ attribute?
    try:
        return a_thing.__name__
    except AttributeError:
        # nope, not one of these
        pass
    # punt and see what happens if we just cast it to string
    return str(a_thing)
1339491
def pretty_str(self, indent=0):
        
        spaces = ' ' * indent
        pretty = spaces + 'class ' + self.name
        if self.superclasses:
            superclasses = ', '.join(self.superclasses)
            pretty += '(' + superclasses + ')'
        pretty += ':\n'
        if self.members:
            pretty += '\n\n'.join(
                    c.pretty_str(indent + 2)
                    for c in self.members
            )
        else:
            pretty += spaces + '  [declaration]'
        return pretty