Adapt the input from web.py for the inginious.backend
352142
def adapt_input_for_backend(self, input_data):
        
        for problem in self._problems:
            input_data = problem.adapt_input_for_backend(input_data)
        return input_data
248907
def _load_backend(self, backend_uri, context):
        
        parsed = parse.urlparse(backend_uri)
        options = dict(parse.parse_qsl(parsed.query))

        try:
            backend = self._entry_points[self.BACKENDS_ENTRY_POINT][parsed.scheme].load()
        except KeyError:
            raise BackendNotFoundError(
                "The requested backend `%s` could not be found in the "
                "registered entry points. Perhaps you forgot to install the "
                "corresponding backend package?" % parsed.scheme
            )

        password = (parse.unquote(parsed.password)
                    if parsed.password
                    else parsed.password)

        return backend(
            username=parsed.username, password=password,
            hostname=parsed.hostname, port=parsed.port,
            path=parsed.path, options=options, context=context,
        )
504615
def process_response(self, request, response, spider):
        """"""
        return response.replace(body=str(BeautifulSoup(response.body, self.parser)))
1198381
def gen_input_add(sig_dic):
    '''
    
    '''
    if sig_dic['en'] == 'tag_file_download':
        html_str = HTML_TPL_DICT['input_add_download'].format(
            sig_en=sig_dic['en'],
            sig_zh=sig_dic['zh'],
            sig_dic=sig_dic['dic'][1],
            sig_type=sig_dic['type']
        )
    else:
        html_str = HTML_TPL_DICT['input_add'].format(
            sig_en=sig_dic['en'],
            sig_zh=sig_dic['zh'],
            sig_dic=sig_dic['dic'][1],
            sig_type=sig_dic['type']
        )
    return html_str
675841
def use(backend):
    
    global Backend

    try:
        Backend = importlib.import_module(backend)
    except ImportError:
        msg = 'Could not import (load) database.backend: %s' % backend
        raise cfg.AitConfigError(msg)
1101827
def Setup(self, input, URL, encoding, options):
        
        if input is None: input__o = None
        else: input__o = input._o
        ret = libxml2mod.xmlTextReaderSetup(self._o, input__o, URL, encoding, options)
        return ret
1060540
def set_backend(database):
    
    new_backend = BACKENDS.get(database.lower())
    if not new_backend:
        raise Exception('Backend {} is not supported.'.format(database))
    global BACKEND  # pylint: disable=global-statement
    BACKEND = new_backend
239616
def application(environ, start_response):
    """"""
    # the environment variable CONTENT_LENGTH may be empty or missing
    try:
        request_body_size = int(environ.get('CONTENT_LENGTH', 0))
    except ValueError:
        request_body_size = 0

    # When the method is POST the query string will be sent
    # in the HTTP request body which is passed by the WSGI server
    # in the file like wsgi.input environment variable.
    if request_body_size > 0:
        request_body = environ['wsgi.input'].read(request_body_size)
    else:
        request_body = environ['wsgi.input'].read()
    form = cgi.parse_qs(request_body)

    status = '200 OK'
    start_response(status, get_response_headers())
    for output in checklink(form=form, env=environ):
        yield output
2964
def call(input)
      context = input[:environment].context_class.new(input)

      engine_options = merge_options({
        filename: input[:filename],
        syntax: self.class.syntax,
        cache_store: build_cache_store(input, @cache_version),
        load_paths: context.environment.paths.map { |p| @importer_class.new(p.to_s) },
        importer: @importer_class.new(Pathname.new(context.filename).to_s),
        sprockets: {
          context: context,
          environment: input[:environment],
          dependencies: context.metadata[:dependencies]
        }
      })

      engine = Autoload::Sass::Engine.new(input[:data], engine_options)

      css, map = Utils.module_include(Autoload::Sass::Script::Functions, @functions) do
        engine.render_with_sourcemap('')
      end

      css = css.sub("\n/*# sourceMappingURL= */\n", '')

      map = SourceMapUtils.format_source_map(JSON.parse(map.to_json(css_uri: '')), input)
      map = SourceMapUtils.combine_source_maps(input[:metadata][:map], map)

      # Track all imported files
      sass_dependencies = Set.new([input[:filename]])
      engine.dependencies.map do |dependency|
        sass_dependencies << dependency.options[:filename]
        context.metadata[:dependencies] << URIUtils.build_file_digest_uri(dependency.options[:filename])
      end

      context.metadata.merge(data: css, sass_dependencies: sass_dependencies, map: map)
    end
1215651
def init_config(args):
    
    os.environ["AUTOMLBOARD_LOGDIR"] = args.logdir
    os.environ["AUTOMLBOARD_LOGLEVEL"] = args.log_level
    os.environ["AUTOMLBOARD_RELOAD_INTERVAL"] = str(args.reload_interval)

    if args.db:
        try:
            db_address_reg = re.compile(r"(.*)://(.*):(.*)@(.*):(.*)/(.*)")
            match = re.match(db_address_reg, args.db_address)
            os.environ["AUTOMLBOARD_DB_ENGINE"] = match.group(1)
            os.environ["AUTOMLBOARD_DB_USER"] = match.group(2)
            os.environ["AUTOMLBOARD_DB_PASSWORD"] = match.group(3)
            os.environ["AUTOMLBOARD_DB_HOST"] = match.group(4)
            os.environ["AUTOMLBOARD_DB_PORT"] = match.group(5)
            os.environ["AUTOMLBOARD_DB_NAME"] = match.group(6)
            logger.info("Using %s as the database backend." % match.group(1))
        except BaseException as e:
            raise DatabaseError(e)
    else:
        logger.info("Using sqlite3 as the database backend, "
                    "information will be stored in automlboard.db")

    os.environ.setdefault("DJANGO_SETTINGS_MODULE",
                          "ray.tune.automlboard.settings")
    django.setup()
    command = [os.path.join(root_path, "manage.py"), "migrate", "--run-syncdb"]
    execute_from_command_line(command)
1255446
def backend_from_fobj(f):
    """"""
    if magic is None:
        warn("magic lib is not installed; assuming mime type %r" % (
            DEFAULT_MIME))
        return backend_from_mime(DEFAULT_MIME)
    else:
        offset = f.tell()
        try:
            f.seek(0)
            chunk = f.read(MAGIC_BUFFER_SIZE)
            mime = magic.from_buffer(chunk, mime=True)
            return backend_from_mime(mime)
        finally:
            f.seek(offset)
995405
def gatherInput(**Config):
  
  """
  _type = Config.get('type')

  while True:
    try:
      got = raw_input('%s: ' % getLabel(Config))

    except EOFError:
      got = None

    if not got and 'default' in Config:
      return Config['default']

    try:
      return _type(got) if _type else got

    except ValueError as e:
      err(str(e) or '<invalid value>')

    except TypeError:
      err(str(e) or '<invalid value>')
335172
def execute(self, requests, resp_generator, *args, **kwargs):
        '''
            
        '''
        return [resp_generator(request) for request in requests]
69882
def apply(self, value, input_ranges, backend=None):
        
        from .overlay import CompositeOverlay
        if backend is None: backend = Store.current_backend
        kwargs = {k: v for k, v in self.kwargs.items() if k != 'output_type'}
        if isinstance(value, CompositeOverlay) and len(value) == 1:
            value = value.values()[0]
            if self.transfer_parameters:
                plot_opts = Store.lookup_options(backend, value, 'plot').kwargs
                kwargs.update({k: v for k, v in plot_opts.items()
                               if k in self.operation.params()})

        transformed = self.operation(value, input_ranges=input_ranges, **kwargs)
        if self.transfer_options:
            Store.transfer_options(value, transformed, backend)
        return transformed
1186859
def to_html(options = :DEFAULT, extensions = [])
      opts = Config.process_options(options, :render)
      _render_html(opts, extensions).force_encoding('utf-8')
    end
201621
def _validate_backend(self):
        
        try:
            self.backend_class
        # if we get an import error the specified path is wrong
        except (ImportError, AttributeError) as e:
            raise ValidationError(_('No valid backend found, got the following python exception: "%s"') % e)
571050
def AsJonPy(request=None, modules=None, **kw):
    '''
    '''

    kw['request'] = request
    if request.environ.get('REQUEST_METHOD') != 'POST':
        _JonPySendFault(Fault(Fault.Client, 'Must use POST'), **kw)
        return
    ct = request.environ['CONTENT_TYPE']
    try:
        if ct.startswith('multipart/'):
            cid = resolvers.MIMEResolver(ct, request.stdin)
            xml = cid.GetSOAPPart()
            ps = ParsedSoap(xml, resolver=cid.Resolve)
        else:
            length = int(request.environ['CONTENT_LENGTH'])
            ps = ParsedSoap(request.stdin.read(length))
    except ParseException, e:
        _JonPySendFault(FaultFromZSIException(e), **kw)
        return
    _Dispatch(ps, modules, _JonPySendXML, _JonPySendFault, **kw)