Get application formats.

    See :class:`gogoutils.Formats` for available options.

    Args:
        config_handle (configparser.ConfigParser): Instance of configurations.

    Returns:
        dict: Formats in ``{$format_type: $format_pattern}``.
182372
def extract_formats(config_handle):
    
    configurations = dict(config_handle)
    formats = dict(configurations.get('formats', {}))
    return formats
306992
def get_format_suffix(self, **kwargs):
        
        if self.settings.FORMAT_SUFFIX_KWARG:
            return kwargs.get(self.settings.FORMAT_SUFFIX_KWARG)
946215
def _format(self, ans, q):
        
        if 'fmt' in q:
            fmt = q['fmt'][0]
        else:
            fmt = 'json'

        fmt = fmt.lower()

        if fmt in self._formatters:
            return (200, self._formatters[fmt](ans, q), 'application/json')
        else:
            return (415,
                'Invalid fmt request "%s", supported formats are: %s\n'%
                    (fmt, ' '.join(self._formatters.keys()),),
                'text/plain')
1014850
def get_serializer(serializer_format):
    
    if serializer_format == Format.JSON:
        return _serialize_json
    if serializer_format == Format.PICKLE:
        return _serialize_pickle
1036426
def get_handlers(self):
        
        handlers = []
        self.static_root = self.application.get_app_component(
        ).get_component_path()
        if self.conf:
            if 'maps' in self.conf:
                if self.conf['maps'] is None:
                    logger.warning("Maps configuration is empty. Finish the"
                                   "static maps configuration.")
                    return handlers
                for map_item in self.conf['maps']:
                    logger.debug("Mapping %s handlers." % map_item['name'])
                    self.static_maps[map_item['name']] = {}
                    self.static_maps[
                        map_item['name']]['root'] = self.static_root
                    if 'root' in map_item:
                        if os.path.isabs(map_item['root']):
                            self.static_maps[
                                map_item['name']]['root'] = map_item['root']
                        else:
                            self.static_maps[
                                map_item['name']]['root'] = os.path.abspath(
                                os.path.join(self.static_root,
                                             map_item['root']))
                    if 'handlers' in map_item:
                        if map_item['handlers'] is None:
                            logger.warning("There is no handles mapped in the"
                                           " static maps config file.")
                        else:
                            handlers = handlers + self.get_static_handlers(
                                map_item)
        else:
            logger.warning("No static maps configurations were provided.")
        return handlers
1220201
def config_get(self, pattern='*'):
        
        result = {}
        for name, value in self.redis_config.items():
            if fnmatch.fnmatch(name, pattern):
                try:
                    result[name] = int(value)
                except ValueError:
                    result[name] = value
        return result
521906
def default_output_format(content_type='application/json', apply_globally=False, api=None, cli=False, http=True):
    """"""
    def decorator(formatter):
        formatter = hug.output_format.content_type(content_type)(formatter)
        if apply_globally:
            if http:
                hug.defaults.output_format = formatter
            if cli:
                hug.defaults.cli_output_format = formatter
        else:
            apply_to_api = hug.API(api) if api else hug.api.from_object(formatter)
            if http:
                apply_to_api.http.output_format = formatter
            if cli:
                apply_to_api.cli.output_format = formatter
        return formatter
    return decorator
236735
def get_default_config_help(self):
        
        config = super(RiemannHandler, self).get_default_config_help()

        config.update({
            'host': '',
            'port': '',
            'transport': 'tcp or udp',
        })

        return config
238015
def configparser(self):
        
        if self._configparser_adapter is None:
            self._configparser_adapter = ConfigPersistenceAdapter(
                config=self,
                reader_writer=ConfigParserReaderWriter(
                    config_parser_factory=self.settings.configparser_factory,
                ),
            )
        return self._configparser_adapter
454828
def get_ext(self, format=None, **kwargs):
        
        try:
            format = format or self.default_params['format']
            return ".%s" % format.lower()
        except KeyError: pass
354467
def format(self, options=None):
        
        if options is None:
            options = conf.lib.clang_defaultDiagnosticDisplayOptions()
        if options & ~Diagnostic._FormatOptionsMask:
            raise ValueError('Invalid format options')
        formatted = conf.lib.clang_formatDiagnostic(self, options)
        return str(conf.lib.clang_getCString(formatted))
157277
def get_runtime_configuration(self):
        # type: () -> RuntimeConfiguration
        
        request_mapper = GenericRequestMapper(
            request_handler_chains=self.request_handler_chains)
        exception_mapper = GenericExceptionMapper(
            exception_handlers=self.exception_handlers)
        handler_adapter = GenericHandlerAdapter()

        runtime_configuration = RuntimeConfiguration(
            request_mappers=[request_mapper],
            handler_adapters=[handler_adapter],
            exception_mapper=exception_mapper,
            request_interceptors=self.global_request_interceptors,
            response_interceptors=self.global_response_interceptors)

        return runtime_configuration
1169763
def default_input_format(content_type='application/json', apply_globally=False, api=None):
    """"""
    def decorator(formatter):
        formatter = hug.output_format.content_type(content_type)(formatter)
        if apply_globally:
            hug.defaults.input_format[content_type] = formatter
        else:
            apply_to_api = hug.API(api) if api else hug.api.from_object(formatter)
            apply_to_api.http.set_input_format(content_type, formatter)
        return formatter
    return decorator
1190747
def _get_config(config_file):
    ''''''
    parser = ConfigParser.SafeConfigParser()
    if os.path.lexists(config_file):
        try:
            log.info('Reading config: %s', config_file)
            inp = open(config_file)
            parser.readfp(inp)
            return parser
        except (IOError, ConfigParser.ParsingError), err:
            raise ConfigError("Failed to read configuration %s\n%s" % (config_file, err))
    return None
1051248
def get_formatter(self, handler):
        
        if isinstance(handler, logging.handlers.SysLogHandler):
            formatter = '[%(levelname)-9s]'
        else:
            formatter = '[%(asctime)s] [%(levelname)-9s]'

        for p in self.prefix:
            formatter += ' [%s]' % (p)
        formatter = formatter + ' %(message)s'
        return logging.Formatter(formatter)
1054187
def get_value_format(value_format: Union[Callable, str] = str) -> Callable[[float], str]:
    
    if value_format is None:
        value_format = ""
    if isinstance(value_format, str):
        format_str = "{0:" + value_format + "}"

        def value_format(x): return format_str.format(x)

    return value_format
763230
def get_format(self):
        
        url = self.build_url(self._endpoints.get('get_format'))
        response = self.session.get(url)
        if not response:
            return None
        return self.range_format_constructor(parent=self, **{self._cloud_data_key: response.json()})