Outputs a BeautifulSoup object as a string that should hopefully be minimally modified
1866
def _get_bs4_string(soup):
    
    if len(soup.find_all("script")) == 0:
        soup_str = soup.prettify(formatter=None).strip()
    else:
        soup_str = str(soup.html)
        soup_str = re.sub("&amp;", "&", soup_str)
        soup_str = re.sub("&lt;", "<", soup_str)
        soup_str = re.sub("&gt;", ">", soup_str)
    return soup_str
933548
def pretty_str(self, indent=0):
        
        indent = ' ' * indent
        pretty = '{}({})' if self.parenthesis else '{}{}'
        args = ', '.join(map(pretty_str, self.arguments))
        if self.method_of:
            call = '{}.{}({})'.format(self.method_of.pretty_str(),
                                      self.name, args)
        elif self.is_constructor:
            call = 'new {}({})'.format(self.name, args)
        else:
            call = '{}({})'.format(self.name, args)
        return pretty.format(indent, call)
607778
function objectToString(o) {
  return '{' + keys(o).map(k => `${k}: ${o[k]}`).join(', ') + '}';
}
999185
function htmlStringify(obj, fromRecur) {

	var tag = (fromRecur) ? 'span' : 'div';
	var nextLevel = (fromRecur || 0) + 1;
	
	// strings
	if (typeof obj == 'string') {
		return '<' + tag + ' style="color: #0e4889; cursor: default;">"' + obj + '"</' + tag + '>';
	}
	// booleans, null and undefined
	else if (typeof obj == 'boolean' || obj === null || obj === undefined) {
		return '<' + tag + '><em style="color: #06624b; cursor: default;">' + obj + '</em></' + tag + '>';
	}
	// numbers
	else if (typeof obj == 'number') {
		return '<' + tag + ' style="color: #ca000a; cursor: default;">' + obj + '</' + tag + '>';
	}
	// dates
	else if (Object.prototype.toString.call(obj) == '[object Date]') {
		return '<' + tag + ' style="color: #009f7b; cursor: default;">' + obj + '</' + tag + '>';
	}
	// arrays
	else if (Array.isArray(obj)) {
		
		var rtn = '<' + tag + ' style="color: #666; cursor: default;">Array: [';
		
		if (!obj.length) {
			return rtn + ']</' + tag + '>';
		}
		
		rtn += '</' + tag + '><div style="padding-left: 20px;">';
		
		for (var i = 0; i < obj.length; i++) {
			rtn += '<span></span>' + htmlStringify(obj[i], nextLevel); // give the DOM structure has as many elements as an object, for collapse behaviour
			if (i < obj.length - 1) {
				rtn += ', <br>';
			}
		}
	
		return rtn + '</div><' + tag + ' style="color: #666">]</' + tag + '>';
		
	}
	// objects
	else if (obj && typeof obj == 'object') {
		
		var rtn = '',
			len = Object.keys(obj).length;
	
		if (fromRecur && !len) {
			return '<' + tag + ' style="color: #999; cursor: default;">Object: {}</' + tag + '>';
		}
		
		if (fromRecur) {
			rtn += '<' + tag + ' style="color: #0b89b6">Object: {</' + tag + '><div class="_stringify_recur _stringify_recur_level_' + fromRecur + '" style="padding-left: 20px;">';
		}
		
		for (var key in obj) {
			if (typeof obj[key] != 'function') {
				rtn += '<div><span style="padding-right: 5px; cursor: default;">' +key + ':</span>' + htmlStringify(obj[key], nextLevel) + '</div>';
			}
		}
		
		if (fromRecur) {
			rtn += '</div><' + tag + ' style="color: #0b89b6; cursor: default;">}</' + tag + '>';
		}
		
		return rtn;
		
	}

	return '';

}
193051
def to_html(self):
        
        if self.items is None:
            return
        else:
            html = '<ol%s>\n' % self.html_attributes()
            for item in self.items:
                html += '<li>%s</li>\n' % item.to_html()
            html += '</ol>'
            return html
161345
def soup(self):
        '''
            
        '''
        components_soup = Tag(name=self.tagname, builder=BUILDER)
        components_soup.attrs = self.attributes
        for c in flatten(self.components):
            if hasattr(c, 'soup'):
                components_soup.append(c.soup())
            elif type(c) in (str, ):
                # components_soup.append(BeautifulSoup(str(c)))
                components_soup.append(str(c))
            # else:
                # Component should not be integrated
                # pass
        return components_soup
1282095
def str_def(self):
        
        return "classname={!r}; min_api_version={!r}; api_version={!r}; " \
            "message={!r};". \
            format(self.__class__.__name__, self.min_api_version,
                   self.api_version, self.args[0])
1046189
def xmlstring(self, pretty_print=False):
        """"""
        s = ElementTree.tostring(self.xml(), xml_declaration=False, pretty_print=pretty_print, encoding='utf-8')
        if sys.version < '3':
            if isinstance(s, str):
                s = unicode(s,'utf-8') #pylint: disable=undefined-variable
        else:
            if isinstance(s,bytes):
                s = str(s,'utf-8')

        s = s.replace('ns0:','') #ugly patch to get rid of namespace prefix
        s = s.replace(':ns0','')
        return s
976597
def obj2str(obj):
    """"""
    if isinstance(obj, str_types):
        return obj.encode("utf-8")
    elif isinstance(obj, pathlib.Path):
        return obj2str(str(obj))
    elif isinstance(obj, (bool, int, float)):
        return str(obj).encode("utf-8")
    elif obj is None:
        return b"none"
    elif isinstance(obj, np.ndarray):
        return obj.tostring()
    elif isinstance(obj, tuple):
        return obj2str(list(obj))
    elif isinstance(obj, list):
        return b"".join(obj2str(o) for o in obj)
    elif isinstance(obj, dict):
        return obj2str(list(obj.items()))
    elif hasattr(obj, "identifier"):
        return obj2str(obj.identifier)
    elif isinstance(obj, h5py.Dataset):
        return obj2str(obj[0])
    else:
        raise ValueError("No rule to convert object '{}' to string.".
                         format(obj.__class__))
1135049
function css_string(css_object) {
    var result = "";
    if ("object" == typeof css_object) {
        for (var key in css_object) {
            result += key + ":" + css_object[key] + ";";
        }
    }
    return result;
}
991606
function outputString(object, writer) {
		if (typeof(object) !== "string") { //$NON-NLS-0$
			if (object.xhr && object.xhr.statusText) {
				/* server error object */
				object = object.xhr.statusText;
			} else {
				object = object.toString();
			}
		}
		return writer.write(object);
	}
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)
622720
def _tostr(self,obj):
        
        if not obj:
            return ''
        if isinstance(obj, list):
            return ', '.join(map(self._tostr, obj))
        return str(obj)
537887
def _raw(s):
    """"""

    if isinstance(s, list):
        s = "\n".join(_raw(item) for item in s)

    if s == EOF:
        return "EOF"

    s = repr(s)  # Get raw representation of string
    s = s[1:-1]  # Strip away quotation marks
    if len(s) > 15:
        s = s[:15] + "..."  # Truncate if too long
    return s
1078647
def make_string(obj):
    
    if inspect.isclass(obj):
        if issubclass(obj, Object):
            return obj._ROOT.__name__
        if issubclass(obj, string_types):
            return 'string'
        return obj.__name__
    if not isinstance(obj, string_types):
        raise TypeError("expected string or class")
    return obj
965796
def _to_python(input_string):
    ''' '''
    python_string = ''
    for i in range(len(input_string)):
        if not python_string:
            python_string += input_string[i].lower()
        elif input_string[i].isupper():
            python_string += '_%s' % input_string[i].lower()
        else:
            python_string += input_string[i]
    return python_string
1295213
def _xml_pretty_print(self, data):
        
        raw_string = xtree.tostring(data, 'utf-8')
        parsed_string = minidom.parseString(raw_string)
        return parsed_string.toprettyxml(indent='\t')