Python werkzeug.datastructures.ImmutableMultiDict() Examples

The following are 30 code examples of werkzeug.datastructures.ImmutableMultiDict(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module werkzeug.datastructures , or try the search function .
Example #1
Source File: test_flask_requests.py    From openapi-core with BSD 3-Clause "New" or "Revised" License 8 votes vote down vote up
def test_simple(self, request_factory, request):
        request = request_factory('GET', '/', subdomain='www')

        openapi_request = FlaskOpenAPIRequest(request)

        path = {}
        query = ImmutableMultiDict([])
        headers = EnvironHeaders(request.environ)
        cookies = {}
        assert openapi_request.parameters == RequestParameters(
            path=path,
            query=query,
            header=headers,
            cookie=cookies,
        )
        assert openapi_request.method == request.method.lower()
        assert openapi_request.full_url_pattern == \
            urljoin(request.host_url, request.path)
        assert openapi_request.body == request.data
        assert openapi_request.mimetype == request.mimetype 
Example #2
Source File: requests.py    From openapi-core with BSD 3-Clause "New" or "Revised" License 7 votes vote down vote up
def create(cls, request):
        method = request.method.lower()

        cookie = request.cookies or {}

        # gets deduced by path finder against spec
        path = {}

        mimetype = request.headers.get('Accept') or \
            request.headers.get('Content-Type')
        parameters = RequestParameters(
            query=ImmutableMultiDict(request.params),
            header=request.headers,
            cookie=cookie,
            path=path,
        )
        return OpenAPIRequest(
            full_url_pattern=request.url,
            method=method,
            parameters=parameters,
            body=request.data,
            mimetype=mimetype,
        ) 
Example #3
Source File: request_processor_test.py    From appkernel with Apache License 2.0 6 votes vote down vote up
def test_or_logic():
    query_expression = ImmutableMultiDict(
        [('first_name', 'first Name'), ('last_name', 'last Name'), ('logic', 'OR')])
    res = convert_to_query(['first_name', 'last_name'], query_expression)
    print(('\n{}'.format(res)))
    assert '$or' in res, 'it should contain a key $or'
    assert len(list(res.keys())) == 1, 'it should have only one key'
    query_items = res.get('$or')
    assert len(query_items) == 2, 'the query should have 2 query params'


# def test_in_query():
#     query_expression = "state:[NEW,CLOSED]"
#     service = Service()
#     res = service._Service__convert_to_query(query_expression)
#     print('\n{}'.format(res)) 
Example #4
Source File: test_requests_requests.py    From openapi-core with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_url_rule(self, request_factory, request):
        request = request_factory('GET', '/browse/12/', subdomain='kb')

        openapi_request = RequestsOpenAPIRequest(request)

        # empty when not bound to spec
        path = {}
        query = ImmutableMultiDict([])
        headers = request.headers
        cookies = {}
        assert openapi_request.parameters == RequestParameters(
            path=path,
            query=query,
            header=headers,
            cookie=cookies,
        )
        assert openapi_request.method == request.method.lower()
        assert openapi_request.full_url_pattern == \
            'http://localhost/browse/12/'
        assert openapi_request.body == request.data
        assert openapi_request.mimetype == 'application/json' 
Example #5
Source File: test_requests_requests.py    From openapi-core with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_multiple_values(self, request_factory, request):
        request = request_factory(
            'GET', '/', subdomain='www', query_string='a=b&a=c')

        openapi_request = RequestsOpenAPIRequest(request)

        path = {}
        query = ImmutableMultiDict([
            ('a', 'b'), ('a', 'c'),
        ])
        headers = request.headers
        cookies = {}
        assert openapi_request.parameters == RequestParameters(
            path=path,
            query=query,
            header=headers,
            cookie=cookies,
        )
        assert openapi_request.method == request.method.lower()
        assert openapi_request.full_url_pattern == 'http://localhost/'
        assert openapi_request.body == request.data
        assert openapi_request.mimetype == 'application/json' 
Example #6
Source File: test_requests_requests.py    From openapi-core with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_simple(self, request_factory, request):
        request = request_factory('GET', '/', subdomain='www')

        openapi_request = RequestsOpenAPIRequest(request)

        path = {}
        query = ImmutableMultiDict([])
        headers = request.headers
        cookies = {}
        assert openapi_request.parameters == RequestParameters(
            path=path,
            query=query,
            header=headers,
            cookie=cookies,
        )
        assert openapi_request.method == request.method.lower()
        assert openapi_request.full_url_pattern == 'http://localhost/'
        assert openapi_request.body == request.data
        assert openapi_request.mimetype == 'application/json' 
Example #7
Source File: test_flask_requests.py    From openapi-core with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_multiple_values(self, request_factory, request):
        request = request_factory(
            'GET', '/', subdomain='www', query_string='a=b&a=c')

        openapi_request = FlaskOpenAPIRequest(request)

        path = {}
        query = ImmutableMultiDict([
            ('a', 'b'), ('a', 'c'),
        ])
        headers = EnvironHeaders(request.environ)
        cookies = {}
        assert openapi_request.parameters == RequestParameters(
            path=path,
            query=query,
            header=headers,
            cookie=cookies,
        )
        assert openapi_request.method == request.method.lower()
        assert openapi_request.full_url_pattern == \
            urljoin(request.host_url, request.path)
        assert openapi_request.body == request.data
        assert openapi_request.mimetype == request.mimetype 
Example #8
Source File: requests.py    From openapi-core with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def create(
            cls, host_url, method, path, path_pattern=None, args=None,
            view_args=None, headers=None, cookies=None, data=None,
            mimetype='application/json'):
        parameters = RequestParameters(
            path=view_args or {},
            query=ImmutableMultiDict(args or []),
            header=headers or {},
            cookie=cookies or {},
        )
        path_pattern = path_pattern or path
        method = method.lower()
        body = data or ''
        full_url_pattern = urljoin(host_url, path_pattern)
        return OpenAPIRequest(
            full_url_pattern=full_url_pattern,
            method=method,
            parameters=parameters,
            body=body,
            mimetype=mimetype,
        ) 
Example #9
Source File: multi.py    From burp-ui with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def store_conf_srv(self, data, conf=None, agent=None):
        """See :func:`burpui.misc.backend.interface.BUIbackend.store_conf_srv`"""
        # serialize data as it is a nested dict
        import hmac
        import hashlib
        from base64 import b64encode
        if not isinstance(data, (_ImmutableMultiDict, ImmutableMultiDict)):
            msg = 'Wrong data type'
            self.logger.warning(msg)
            raise BUIserverException(msg)
        vers = self._get_agent_version()
        if vers and vers >= AGENT_VERSION_CAST:
            # convert the data to our custom ImmutableMultiDict
            data = ImmutableMultiDict(data.to_dict(False))
        key = '{}{}'.format(self.password, 'store_conf_srv')
        key = to_bytes(key)
        pickles = to_unicode(b64encode(pickle.dumps({'data': data, 'conf': conf}, 2)))
        bytes_pickles = to_bytes(pickles)
        digest = to_unicode(hmac.new(key, bytes_pickles, hashlib.sha1).hexdigest())
        data = {'func': 'store_conf_srv', 'args': pickles, 'pickled': True, 'digest': digest}
        return json.loads(self.do_command(data)) 
Example #10
Source File: utils.py    From fence with Apache License 2.0 6 votes vote down vote up
def hash_secret(f):
    @wraps(f)
    def wrapper(*args, **kwargs):
        has_secret = "client_secret" in flask.request.form
        has_client_id = "client_id" in flask.request.form
        if flask.request.form and has_secret and has_client_id:
            form = flask.request.form.to_dict()
            with flask.current_app.db.session as session:
                client = (
                    session.query(Client)
                    .filter(Client.client_id == form["client_id"])
                    .first()
                )
                if client:
                    form["client_secret"] = bcrypt.hashpw(
                        form["client_secret"].encode("utf-8"),
                        client.client_secret.encode("utf-8"),
                    ).decode("utf-8")
                flask.request.form = ImmutableMultiDict(form)

        return f(*args, **kwargs)

    return wrapper 
Example #11
Source File: test_inventory.py    From eNMS with GNU General Public License v3.0 6 votes vote down vote up
def define_device(number: str, description: str) -> ImmutableMultiDict:
    return ImmutableMultiDict(
        [
            ("form_type", "device"),
            ("name", f"description-{number}"),
            ("description", description),
            ("location", "paris"),
            ("vendor", "Cisco"),
            ("icon", "router"),
            ("operating_system", "IOS"),
            ("os_version", "1.4.4.2"),
            ("longitude", "12"),
            ("latitude", "14"),
            ("enable_password", "enable_password"),
        ]
    ) 
Example #12
Source File: model_factories.py    From flask_jsondash with MIT License 6 votes vote down vote up
def make_fake_dashboard(name='Random chart', max_charts=10):
    """Generate fake dashboard data with a specific number of random charts.

    Args:
        name (str): The name of the new dashboard (default: {'Random chart'})
        max_charts (int): Max number of charts to make (default: {10})

    Returns:
        dict: The chart configuration.
    """
    charts = ImmutableMultiDict([
        make_fake_chart_data() for _ in range(max_charts)]
    )
    return dict(
        name=name,
        created_by='global',
        date=dt.now(),
        category=choice(list(settings.CHARTS_CONFIG.keys())),
        modules=db.format_charts(charts),
        id=str(uuid1()),
        layout='freeform',
    ) 
Example #13
Source File: multi.py    From burp-ui with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def store_conf_srv(self, data, conf=None, agent=None):
        """See :func:`burpui.misc.backend.interface.BUIbackend.store_conf_srv`"""
        # serialize data as it is a nested dict
        import hmac
        import hashlib
        from base64 import b64encode
        if not isinstance(data, (_ImmutableMultiDict, ImmutableMultiDict)):
            msg = 'Wrong data type'
            self.logger.warning(msg)
            raise BUIserverException(msg)
        vers = self._get_agent_version()
        if vers and vers >= AGENT_VERSION_CAST:
            # convert the data to our custom ImmutableMultiDict
            data = ImmutableMultiDict(data.to_dict(False))
        key = '{}{}'.format(self.password, 'store_conf_srv')
        key = to_bytes(key)
        pickles = to_unicode(b64encode(pickle.dumps({'data': data, 'conf': conf}, 2)))
        bytes_pickles = to_bytes(pickles)
        digest = to_unicode(hmac.new(key, bytes_pickles, hashlib.sha1).hexdigest())
        data = {'func': 'store_conf_srv', 'args': pickles, 'pickled': True, 'digest': digest}
        return json.loads(self.do_command(data)) 
Example #14
Source File: league.py    From Penny-Dreadful-Tools with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self,
                 form: ImmutableMultiDict,
                 deck_id: int = None,
                 discord_user: int = None) -> None:
        super().__init__(form)
        person_object = None
        if discord_user is not None:
            person_object = person.maybe_load_person_by_discord_id(discord_user)
        if person_object:
            self.decks = active_decks_by_person(person_object.id)
        else:
            self.decks = active_decks()
        self.entry_options = deck_options(self.decks, self.get('entry', deck_id), person_object.id if person_object else None)
        self.discord_user = discord_user
        if len(self.decks) == 0:
            self.errors['entry'] = "You don't have any decks to retire" 
Example #15
Source File: league.py    From Penny-Dreadful-Tools with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self,
                 form: ImmutableMultiDict,
                 deck_id: int = None,
                 person_id: int = None) -> None:
        super().__init__(form)

        decks = active_decks()
        if person_id is not None:
            entry_decks = active_decks_by_person(person_id)
        else:
            entry_decks = decks

        self.entry_options = deck_options(entry_decks, self.get('entry', deck_id), person_id)
        self.opponent_options = deck_options([d for d in decks if d.person_id != person_id], self.get('opponent', None), person_id)
        self.result_options = [
            {'text': 'Win 2–0', 'value': '2–0', 'selected': self.get('result', None) == '2–0'},
            {'text': 'Win 2–1', 'value': '2–1', 'selected': self.get('result', None) == '2–1'},
            {'text': 'Lose 1–2', 'value': '1–2', 'selected': self.get('result', None) == '1–2'},
            {'text': 'Lose 0–2', 'value': '0–2', 'selected': self.get('result', None) == '0–2'},
        ] 
Example #16
Source File: league.py    From Penny-Dreadful-Tools with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self,
                 form: ImmutableMultiDict,
                 person_id: Optional[int],
                 mtgo_username: Optional[str]) -> None:
        super().__init__(form)
        if person_id is not None:
            ps = person.load_person_by_id(person_id)
            self.recent_decks: List[Dict[str, Any]] = []
            for d in sorted(ps.decks, key=lambda deck: deck['created_date'], reverse=True)[0:10]:
                recent_deck = {'name': d['name'], 'main': [], 'sb':[]}
                for c in d.maindeck:
                    recent_deck['main'].append('{n} {c}'.format(n=c['n'], c=c['name']))
                for c in d.sideboard:
                    recent_deck['sb'].append('{n} {c}'.format(n=c['n'], c=c['name']))
                self.recent_decks.append({'name':d['name'], 'list':json.dumps(recent_deck)})
        if mtgo_username is not None:
            self.mtgo_username = mtgo_username
        self.deck = Container()
        self.card_errors: Dict[str, Set[str]] = {}
        self.card_warnings: Dict[str, Set[str]] = {} 
Example #17
Source File: repo.py    From gitmostwanted.com with MIT License 6 votes vote down vote up
def filter_by_args(cls, q, args: ImmutableMultiDict):
        lang = args.get('lang')
        if lang != 'All' and (lang,) in cls.language_distinct():
            q = q.filter(cls.language == lang)

        status = args.get('status')
        if status in ('promising', 'hopeless'):
            q = q.filter(cls.status == status)

        if bool(args.get('mature')):
            q = q.filter(cls.mature.is_(True))

        try:
            q = q.filter(cls.full_name.like(str(SearchTerm(args.get('term', '')))))
        except ValueError:
            pass

        return q 
Example #18
Source File: request_processor_test.py    From appkernel with Apache License 2.0 5 votes vote down vote up
def test_simple_query_with_between_query():
    query_expression = ImmutableMultiDict(
        [('birth_date', '>1980-07-01'), ('birth_date', '<1980-07-31'), ('logic', 'AND')])
    res = convert_to_query(['birth_date'], query_expression)
    print(('\n{}'.format(res)))
    assert isinstance(res, dict), 'it should be type of dict'
    assert len(list(res.keys())) == 1, 'it should have only one key'
    assert isinstance(res.get('birth_date'), dict), 'it should be type of dict'
    assert len(res.get('birth_date')) == 2, 'the date parameter should contain 2 elements' 
Example #19
Source File: request_processor_test.py    From appkernel with Apache License 2.0 5 votes vote down vote up
def test_simple_query_with_contains_expression():
    query_expression = ImmutableMultiDict([('first_name', '~first Name')])
    res = convert_to_query(['first_name'], query_expression)
    print(('\n{}'.format(res)))
    assert isinstance(res, dict), 'it should be type of dict'
    assert len(list(res.keys())) == 1, 'it should have only one key'
    assert '$regex' in res.get('first_name') 
Example #20
Source File: request_processor_test.py    From appkernel with Apache License 2.0 5 votes vote down vote up
def test_simple_query_processing():
    query_expression = ImmutableMultiDict([('first_name', 'first Name')])
    res = convert_to_query(['first_name'], query_expression)
    print(('\n{}'.format(res)))
    assert isinstance(res, dict), 'it should be type of dict'
    assert len(list(res.keys())) == 1, 'it should have only one key'
    assert 'first_name' in res, 'it should contain a key named: first_name'
    assert res.get('first_name') == 'first Name', 'the value of the key should be: first Name' 
Example #21
Source File: request_processor_test.py    From appkernel with Apache License 2.0 5 votes vote down vote up
def test_simple_query_with_less_then():
    query_expression = ImmutableMultiDict([('birth_date', '<1980-07-31')])
    res = convert_to_query(['birth_date'], query_expression)
    print(('\n{}'.format(res)))
    assert isinstance(res, dict), 'it should be type of dict'
    assert len(list(res.keys())) == 1, 'it should have only one key'
    assert isinstance(res.get('birth_date'), dict), 'it should be type of dict' 
Example #22
Source File: stash.py    From geofront with GNU Affero General Public License v3.0 5 votes vote down vote up
def authenticate(self,
                     state,
                     requested_redirect_url: str,
                     wsgi_environ: Mapping[str, object]) -> Identity:
        logger = logging.getLogger(__name__ + '.StashTeam.authenticate')
        logger.debug('state = %r', state)
        try:
            oauth_token, oauth_token_secret = state
        except ValueError:
            raise AuthenticationError()
        req = Request(wsgi_environ, populate_request=False, shallow=True)
        args = cast(ImmutableMultiDict, req.args)
        logger.debug('req.args = %r', args)
        if args.get('oauth_token') != oauth_token:
            raise AuthenticationError()
        response = self.request(
            'POST', self.ACCESS_TOKEN_URL.format(self),
            resource_owner_key=oauth_token,
            resource_owner_secret=oauth_token_secret
        )
        access_token = url_decode_stream(response)
        logger.debug('access_token = %r', access_token)
        response.close()
        response = self.request(
            'GET', self.USER_URL.format(self),
            resource_owner_key=access_token['oauth_token'],
            resource_owner_secret=access_token['oauth_token_secret']
        )
        whoami = response.read().decode('utf-8')
        return Identity(
            type(self),
            self.USER_PROFILE_URL.format(self, whoami),
            (access_token['oauth_token'], access_token['oauth_token_secret'])
        ) 
Example #23
Source File: test_inventory.py    From eNMS with GNU General Public License v3.0 5 votes vote down vote up
def define_link(source: int, destination: int) -> ImmutableMultiDict:
    return ImmutableMultiDict(
        [
            ("form_type", "link"),
            ("name", f"{source} too {destination}"),
            ("description", "description"),
            ("location", "Los Angeles"),
            ("vendor", "Juniper"),
            ("source", source),
            ("destination", destination),
        ]
    ) 
Example #24
Source File: test_main.py    From example_dataproc_twitter with MIT License 5 votes vote down vote up
def test_run_job(self, factory_mock):
        job_mock = mock.Mock()
        factory_mock.factor_job.return_value = mock.Mock(return_value=job_mock)
        response = self.test_app.get('/run_job/job_name_test/')
        factory_mock.factor_job.assert_called_once_with(*['job_name_test'])
        job_mock.run.assert_called_once()
        self.assertEqual(response.status_int, 200)

        url = '/run_job/job_name_test/?url=url&target=target'
        response = self.test_app.get(url)
        expected = ImmutableMultiDict([('url', 'url'), ('target', 'target')])
        job_mock.run.assert_called_with(expected)
        self.assertEqual(response.status_int, 200) 
Example #25
Source File: helpers.py    From capybara.py with MIT License 5 votes vote down vote up
def extract_results(session):
    session.assert_selector("//pre[@id='results']")

    tree = etree.HTML(session.body)
    element = tree.xpath("//pre[@id='results']")[0]

    def inner_html(elem):
        return "".join(
            [elem.text or ""] +
            [etree.tostring(child).decode("utf-8") for child in elem] +
            [elem.tail or ""])

    return ImmutableMultiDict(json.loads(inner_html(element))) 
Example #26
Source File: multi.py    From burp-ui with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def store_conf_cli(self, data, client=None, conf=None, template=False,
                       statictemplate=False, content='', agent=None):
        """See :func:`burpui.misc.backend.interface.BUIbackend.store_conf_cli`"""
        # serialize data as it is a nested dict
        import hmac
        import hashlib
        from base64 import b64encode
        if not isinstance(data, (_ImmutableMultiDict, ImmutableMultiDict)):
            msg = 'Wrong data type'
            self.logger.warning(msg)
            raise BUIserverException(msg)
        vers = self._get_agent_version()
        if vers and vers >= AGENT_VERSION_CAST:
            # convert the data to our custom ImmutableMultiDict
            data = ImmutableMultiDict(data.to_dict(False))
        key = '{}{}'.format(self.password, 'store_conf_cli')
        key = to_bytes(key)
        pickles = to_unicode(
            b64encode(
                pickle.dumps(
                    {'data': data, 'conf': conf, 'client': client, 'template': template,
                     'statictemplate': statictemplate, 'content': content}, 2
                )
            )
        )
        bytes_pickles = to_bytes(pickles)
        digest = to_unicode(hmac.new(key, bytes_pickles, hashlib.sha1).hexdigest())
        data = {'func': 'store_conf_cli', 'args': pickles, 'pickled': True, 'digest': digest}
        return json.loads(self.do_command(data)) 
Example #27
Source File: multi.py    From burp-ui with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def store_conf_cli(self, data, client=None, conf=None, template=False,
                       statictemplate=False, content='', agent=None):
        """See :func:`burpui.misc.backend.interface.BUIbackend.store_conf_cli`"""
        # serialize data as it is a nested dict
        import hmac
        import hashlib
        from base64 import b64encode
        if not isinstance(data, (_ImmutableMultiDict, ImmutableMultiDict)):
            msg = 'Wrong data type'
            self.logger.warning(msg)
            raise BUIserverException(msg)
        vers = self._get_agent_version()
        if vers and vers >= AGENT_VERSION_CAST:
            # convert the data to our custom ImmutableMultiDict
            data = ImmutableMultiDict(data.to_dict(False))
        key = '{}{}'.format(self.password, 'store_conf_cli')
        key = to_bytes(key)
        pickles = to_unicode(
            b64encode(
                pickle.dumps(
                    {'data': data, 'conf': conf, 'client': client, 'template': template,
                     'statictemplate': statictemplate, 'content': content}, 2
                )
            )
        )
        bytes_pickles = to_bytes(pickles)
        digest = to_unicode(hmac.new(key, bytes_pickles, hashlib.sha1).hexdigest())
        data = {'func': 'store_conf_cli', 'args': pickles, 'pickled': True, 'digest': digest}
        return json.loads(self.do_command(data)) 
Example #28
Source File: multi.py    From burp-ui with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def store_conf_cli(self, data, client=None, conf=None, template=False,
                       statictemplate=False, content='', agent=None):
        """See :func:`burpui.misc.backend.interface.BUIbackend.store_conf_cli`"""
        # serialize data as it is a nested dict
        import hmac
        import hashlib
        from base64 import b64encode
        if not isinstance(data, (_ImmutableMultiDict, ImmutableMultiDict)):
            msg = 'Wrong data type'
            self.logger.warning(msg)
            raise BUIserverException(msg)
        vers = self._get_agent_version()
        if vers and vers >= AGENT_VERSION_CAST:
            # convert the data to our custom ImmutableMultiDict
            data = ImmutableMultiDict(data.to_dict(False))
        key = '{}{}'.format(self.password, 'store_conf_cli')
        key = to_bytes(key)
        pickles = to_unicode(
            b64encode(
                pickle.dumps(
                    {'data': data, 'conf': conf, 'client': client, 'template': template,
                     'statictemplate': statictemplate, 'content': content}, 2
                )
            )
        )
        bytes_pickles = to_bytes(pickles)
        digest = to_unicode(hmac.new(key, bytes_pickles, hashlib.sha1).hexdigest())
        data = {'func': 'store_conf_cli', 'args': pickles, 'pickled': True, 'digest': digest}
        return json.loads(self.do_command(data)) 
Example #29
Source File: requests.py    From openapi-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def create(cls, request):
        """
        Create OpenAPIRequest from falcon Request and route params.
        """
        method = request.method.lower()

        # gets deduced by path finder against spec
        path = {}

        # Support falcon-jsonify.
        body = (
            dumps(request.json) if getattr(request, "json", None)
            else dumps(request.media)
        )
        mimetype = request.options.default_media_type
        if request.content_type:
            mimetype = request.content_type.partition(";")[0]

        query = ImmutableMultiDict(request.params.items())
        parameters = RequestParameters(
            query=query,
            header=request.headers,
            cookie=request.cookies,
            path=path,
        )
        url_pattern = request.prefix + request.path
        return OpenAPIRequest(
            full_url_pattern=url_pattern,
            method=method,
            parameters=parameters,
            body=body,
            mimetype=mimetype,
        ) 
Example #30
Source File: tools.py    From flaskapp with MIT License 5 votes vote down vote up
def multi_dict_parser2dict(multi_dict):
    if not isinstance(multi_dict, ImmutableMultiDict):
        raise AssertionError('object type must be ImmutableMultiDict')
    return {k: multi_dict[k] for k in multi_dict}