Return a list of the IANA Character Sets, or an empty list if the
    IANA website is unreachable.
    Store it as a function attribute so that we only build the list once.
776488
def char_sets():
    
    if not hasattr(char_sets, 'setlist'):
        clist = []
        try:
            data = requests.get('http://www.iana.org/assignments/character-'
                                'sets/character-sets-1.csv')
        except requests.exceptions.RequestException:
            return []

        for line in data.iter_lines():
            if line:
                line = line.decode("utf-8")
                if line.count(',') > 0:
                    vals = line.split(',')
                    if vals[0]:
                        clist.append(vals[0])
                    else:
                        clist.append(vals[1])

        char_sets.setlist = clist
    return char_sets.setlist
1065149
def _convert_to_unicode(string):
    
    codepoints = []
    for character in string.split('-'):
        if character in BLACKLIST_UNICODE:
            next

        codepoints.append(
            '\U{0:0>8}'.format(character).decode('unicode-escape')
        )

    return codepoints
271652
def nn_symbols():
    ""
    value = ctypes.c_int()
    name_value_pairs = []
    i = 0
    while True:
        name = _nn_symbol(i, ctypes.byref(value))
        if name is None:
            break
        i += 1
        name_value_pairs.append((name.decode('ascii'), value.value))
    return name_value_pairs
613600
def urlencode_params(params):
    
    # urlencode does not handle unicode strings in Python 2.
    # Firstly, normalize the values so they get encoded correctly.
    params = [(key, normalize_for_urlencode(val)) for key, val in params]
    # Secondly, unquote unreserved chars which are incorrectly quoted
    # by urllib.urlencode, causing invalid auth signatures. See GH #72
    # for more info.
    return requests.utils.unquote_unreserved(urlencode(params))
160084
def protocols():
    
    if not hasattr(protocols, 'protlist'):
        plist = []
        try:
            data = requests.get('http://www.iana.org/assignments/service-names'
                                '-port-numbers/service-names-port-numbers.csv')
        except requests.exceptions.RequestException:
            return []

        for line in data.iter_lines():
            if line:
                line = line.decode("utf-8")
                if line.count(',') > 0:
                    vals = line.split(',')
                    if vals[0]:
                        plist.append(vals[0])
                    if len(vals) > 2 and vals[2] and vals[2] not in plist:
                        plist.append(vals[2])

        plist.append('ipv4')
        plist.append('ipv6')
        plist.append('ssl')
        plist.append('tls')
        plist.append('dns')
        protocols.protlist = plist
    return protocols.protlist
1227845
def _asciify_list(data):
    
    ret = []
    for item in data:
        if isinstance(item, unicode):
            item = _remove_accents(item)
            item = item.encode('utf-8')
        elif isinstance(item, list):
            item = _asciify_list(item)
        elif isinstance(item, dict):
            item = _asciify_dict(item)
        ret.append(item)
    return ret
208519
public List<CharSequence> getAsList() {
        if (cache != null) {
            return Collections.singletonList((CharSequence) cache);
        }
        return Collections.unmodifiableList(list);
    }
1216503
def _recursively_convert_unicode_to_str(input):
    
    if isinstance(input, dict):
        return {_recursively_convert_unicode_to_str(key): _recursively_convert_unicode_to_str(value) for key, value in input.items()}
    elif isinstance(input, list):
        return [_recursively_convert_unicode_to_str(element) for element in input]
    elif not PYTHON_3 and isinstance(input, unicode):
        return input.encode('utf-8')
    else:
        return input
38785
def prepare(self, ansi='', ensure_trailing_newline=False):
        

        body, styles = self.apply_regex(ansi)

        if ensure_trailing_newline and _needs_extra_newline(body):
            body += '\n'

        self._attrs = {
            'dark_bg': self.dark_bg,
            'line_wrap': self.line_wrap,
            'font_size': self.font_size,
            'body': body,
            'styles': styles,
        }

        return self._attrs
1234607
def all_unambiguous(sequence_str):
    
    result = [[]]
    for c in sequence_str:
        result = [i + [a] for i in result for a in _AMBIGUOUS_MAP.get(c, c)]
    return [''.join(i) for i in result]
1369917
def bound_symbols(self):
        """"""
        if self._bound_symbols is None:
            res = set.union(
                set([]), # dummy arg (union fails without arguments)
                *[_bound_symbols(val) for val in self.kwargs.values()])
            res.update(
                set([]), # dummy arg (update fails without arguments)
                *[_bound_symbols(arg) for arg in self.args])
            self._bound_symbols = res
        return self._bound_symbols
447590
public List<Charset> getAcceptCharset() {
		List<Charset> result = new ArrayList<Charset>();
		String value = getFirst(ACCEPT_CHARSET);
		if (value != null) {
			String[] tokens = value.split(",\\s*");
			for (String token : tokens) {
				int paramIdx = token.indexOf(';');
				String charsetName;
				if (paramIdx == -1) {
					charsetName = token;
				}
				else {
					charsetName = token.substring(0, paramIdx);
				}
				if (!charsetName.equals("*")) {
					result.add(Charset.forName(charsetName));
				}
			}
		}
		return result;
	}
1366790
def ipa_chars(self, value):
        
        if value is None:
            self.__ipa_chars = []
        else:
            if is_list_of_ipachars(value):
                self.__ipa_chars = value
            else:
                raise TypeError("ipa_chars only accepts a list of IPAChar objects")
979410
def list_symbols(self, partial_match=None):
        
        symbols = self._symbols.distinct(SYMBOL)
        if partial_match is None:
            return symbols
        return [x for x in symbols if partial_match in x]
217948
def GetEncoding(self):
        ''''''
        if self.encoding:
            vals = string.split(self.encoding, ',')
            if len(vals) > 2:
                try:
                    return charset_table[int(vals[2])]
                except KeyError:
                    pass
        return None
885221
def _format_attrs(self):
        
        attrs = [
            ('levels', ibase.default_pprint(self._levels,
                                            max_seq_items=False)),
            ('codes', ibase.default_pprint(self._codes,
                                           max_seq_items=False))]
        if com._any_not_none(*self.names):
            attrs.append(('names', ibase.default_pprint(self.names)))
        if self.sortorder is not None:
            attrs.append(('sortorder', ibase.default_pprint(self.sortorder)))
        return attrs
495843
public static ImmutableList<UnicodeFriendlyString> unicodeFriendlyList(Iterable<String> strings) {
    final ImmutableList.Builder<UnicodeFriendlyString> ret = ImmutableList.builder();

    for (final String s : strings) {
      ret.add(unicodeFriendly(s));
    }

    return ret.build();
  }