Return a generator of formatters codes of type typ
335982
def oftype(self, typ):
        ''''''
        for key, val in self.items():
            if val.type == typ:
                yield key
892600
def highlight(code, lexer='html', formatter='html', output_wrapper=None):
    """"""
    if not pygments:
        raise TypeError("pygments module required")
    if not isinstance(code, six.string_types):
        code = pprint.pformat(code)
    if isinstance(lexer, six.string_types):
        lexer = pygments.lexers.get_lexer_by_name(lexer)
    if isinstance(formatter, six.string_types):
        formatter = pygments.formatters.get_formatter_by_name(formatter)
        if formatter.name.lower() == 'html':
            formatter.full = True
            formatter.cssclass = "pygments-%s" % uuid.uuid4()
            if output_wrapper is None:
                output_wrapper = HTML
    return output_wrapper(pygments.highlight(code, lexer, formatter))
980955
def _gen_code(self):
        """"""
        # This is the dictionary that stores all the generated code.

        self.code = {}
        def match_key(expr):
            if type(expr) is dict:
                code = {}
                for key in expr.keys():
                    code[key] = match_key(expr[key])
            else:
                arg_list = [e for e in expr.atoms() if e.is_Symbol]
                code = self._expr2code(arg_list, expr)
            return code

        self.code = match_key(self.expressions)
403376
def generate_docs(self):
        """"""
        if self.dst.style['out'] == 'numpydoc' and self.dst.numpydoc.first_line is not None:
            self.first_line = self.dst.numpydoc.first_line
        self._set_desc()
        self._set_params()
        self._set_return()
        self._set_raises()
        self._set_other()
        self._set_raw()
        self.generated_docs = True
112362
def list_output_formats(type_list):
    """"""
    out_format_list = []
    for type_item in type_list:
        item_format = default_output_format(type_item)
        out_format_list.append(item_format)

    return out_format_list
790470
def _to_output_code(self):
        """"""
        # All supported Literal objects serialize to identical strings both in Gremlin and MATCH.
        self.validate()
        if self.value is None:
            return u'null'
        elif self.value is True:
            return u'true'
        elif self.value is False:
            return u'false'
        elif isinstance(self.value, six.string_types):
            return safe_quoted_string(self.value)
        elif isinstance(self.value, int):
            return six.text_type(self.value)
        elif isinstance(self.value, list):
            if len(self.value) == 0:
                return '[]'
            elif all(isinstance(x, six.string_types) for x in self.value):
                list_contents = ', '.join(safe_quoted_string(x) for x in sorted(self.value))
                return '[' + list_contents + ']'
        else:
            pass  # Fall through to assertion error below.
        raise AssertionError(u'Unreachable state reached: {}'.format(self))
1308018
def _iter_lexerclasses(plugins=True):
    """"""
    for key in sorted(LEXERS):
        module_name, name = LEXERS[key][:2]
        if name not in _lexer_cache:
            _load_lexers(module_name)
        yield _lexer_cache[name]
    if plugins:
        for lexer in find_plugin_lexers():
            yield lexer
59986
def guess_type(typ):
    ''''''
    # Strip useless numbers
    match = re.match("([a-zA-Z]+)\d*", typ)
    if match:
        typ = match.groups()[0]
        return typ
325238
def columns_formatter(cls, colname):
        """"""
        def wrapper(func):
            cls.columns_formatters[colname] = func
            return func
        return wrapper
114054
def dbType(self, typ):
        
        return self.TypeMap.get(typ, self.TypeMap.get('Default'))
1121064
def construct_format(f, type_map=CONSTRUCT_CODE):
  
  formatted = ""
  if type_map.get(f.type_id, None):
    return "%s('%s')" % (type_map.get(f.type_id), f.identifier)
  elif f.type_id == 'string' and f.options.get('size', None):
    return "string('%s', { length: %d })" % (f.identifier, f.options['size'].value)
  elif f.type_id == 'string':
    return "string('%s', { greedy: true })" % (f.identifier)
  elif f.type_id == 'array':
    fill = f.options['fill'].value
    f_ = copy.copy(f)
    f_.type_id = fill
    size = f.options.get('size', None)
    size_fn = f.options.get('size_fn', None)
    field_type = type_map.get(f_.type_id, None)
    if field_type is None:
      field_type = "%s.prototype.parser" % f_.type_id
    else:
      field_type = "'%s'" % field_type
    if size is not None:
      d = { "'uint16'" : "'uint16le'", "'uint32'" : "'uint32le'", "'uint64'" : "'uint16le'",
            "'int16'" : "'int16le'", "'int32'" : "'int32le'", "'int64'" : "'int16le'" }
      field_type_arr = d.get(field_type, field_type)
      return "array('%s', { length: %d, type: %s })" % (f.identifier, size.value, field_type_arr)
    elif f.options.get('size_fn') is not None:
      return "array('%s', { type: %s, length: '%s' })" % (f_.identifier, field_type, size_fn.value)
    else:
      return "array('%s', { type: %s, readUntil: 'eof' })" % (f_.identifier, field_type)
  else:
    return "nest('%s', { type: %s.prototype.parser })" % (f.identifier, f.type_id)
  return formatted
342671
function getFormatter(oType) {
		var oFormatOptions, iScale;

		if (!oType.oFormat) {
			oFormatOptions = {
				groupingEnabled : true,
				maxIntegerDigits : Infinity
			};
			iScale = getScale(oType);
			if (iScale !== Infinity) {
				oFormatOptions.minFractionDigits = oFormatOptions.maxFractionDigits = iScale;
			}
			oFormatOptions = jQuery.extend(oFormatOptions, oType.oFormatOptions);
			oFormatOptions.parseAsString = true;
			oType.oFormat = NumberFormat.getFloatInstance(oFormatOptions);
		}
		return oType.oFormat;
	}
968835
def format_kinds(raw):
    """"""
    output = ' '.join('{} {}'.format(*kind) for kind in raw if kind)
    return output
716690
def formatters(*chained_formatters):
    
    def formatters_chain(input_string):  # pylint:disable=missing-docstring
        for chained_formatter in chained_formatters:
            input_string = chained_formatter(input_string)
        return input_string

    return formatters_chain
1350348
def _generate_union_class_get_helpers(self, ns, data_type):
        
        for field in data_type.fields:
            field_name = fmt_func(field.name)

            if not is_void_type(field.data_type):
                # generate getter for field
                self.emit('def get_{}(self):'.format(field_name))
                with self.indent():
                    if is_nullable_type(field.data_type):
                        field_dt = field.data_type.data_type
                    else:
                        field_dt = field.data_type
                    self.emit('"""')
                    if field.doc:
                        self.emit_wrapped_text(
                            self.process_doc(field.doc, self._docf))
                        self.emit()
                    self.emit("Only call this if :meth:`is_%s` is true." %
                              field_name)
                    # Sphinx wants an extra line between the text and the
                    # rtype declaration.
                    self.emit()
                    self.emit(':rtype: {}'.format(
                        self._python_type_mapping(ns, field_dt)))
                    self.emit('"""')

                    self.emit('if not self.is_{}():'.format(field_name))
                    with self.indent():
                        self.emit(
                            'raise AttributeError("tag \'{}\' not set")'.format(
                                field_name))
                    self.emit('return self._value')
                self.emit()
843295
def get_formatter(name):
    
    for k in sorted(_FORMATTERS):
        if k.startswith(name):
            return _FORMATTERS[k]
1202121
def construct_format(f, type_map=CONSTRUCT_CODE):
  
  formatted = ""
  if type_map.get(f.type_id, None):
    return "'{identifier}' / {type_id}".format(type_id=type_map.get(f.type_id),
                                             identifier=f.identifier)
  elif f.type_id == 'string' and f.options.get('size', None):
    return "'{id}'/ construct.Bytes({size})".format(id=f.identifier,
                                                   size=f.options['size'].value)
  elif f.type_id == 'string':
    return "'{id}' / construct.GreedyBytes".format(id=f.identifier)
  elif f.type_id == 'array' and f.options.get('size', None):
    fill = f.options['fill'].value
    f_ = copy.copy(f)
    f_.type_id = fill
    s = f.options.get('size', None).value
    return "'{id}' / construct.Array({size}, {type})".format(id=f.identifier, size=s, type=type_map.get(f_.type_id, 'construct.Byte'))
  elif f.type_id == 'array':
    fill = f.options['fill'].value
    f_ = copy.copy(f)
    f_.type_id = fill
    return "construct.GreedyRange(%s)" % construct_format(f_)
  else:
    return "'%s' / construct.Struct(%s._parser)" % (f.identifier, f.type_id)
  return formatted