当前位置: 首页>>代码示例>>Python>>正文


Python datastructures.ImmutableMultiDict方法代码示例

本文整理汇总了Python中werkzeug.datastructures.ImmutableMultiDict方法的典型用法代码示例。如果您正苦于以下问题:Python datastructures.ImmutableMultiDict方法的具体用法?Python datastructures.ImmutableMultiDict怎么用?Python datastructures.ImmutableMultiDict使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在werkzeug.datastructures的用法示例。


在下文中一共展示了datastructures.ImmutableMultiDict方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from werkzeug import datastructures [as 别名]
# 或者: from werkzeug.datastructures import ImmutableMultiDict [as 别名]
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]] = {} 
开发者ID:PennyDreadfulMTG,项目名称:Penny-Dreadful-Tools,代码行数:22,代码来源:league.py

示例2: hash_secret

# 需要导入模块: from werkzeug import datastructures [as 别名]
# 或者: from werkzeug.datastructures import ImmutableMultiDict [as 别名]
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 
开发者ID:uc-cdis,项目名称:fence,代码行数:25,代码来源:utils.py

示例3: create

# 需要导入模块: from werkzeug import datastructures [as 别名]
# 或者: from werkzeug.datastructures import ImmutableMultiDict [as 别名]
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,
        ) 
开发者ID:p1c2u,项目名称:openapi-core,代码行数:25,代码来源:requests.py

示例4: create

# 需要导入模块: from werkzeug import datastructures [as 别名]
# 或者: from werkzeug.datastructures import ImmutableMultiDict [as 别名]
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,
        ) 
开发者ID:p1c2u,项目名称:openapi-core,代码行数:23,代码来源:requests.py

示例5: test_simple

# 需要导入模块: from werkzeug import datastructures [as 别名]
# 或者: from werkzeug.datastructures import ImmutableMultiDict [as 别名]
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 
开发者ID:p1c2u,项目名称:openapi-core,代码行数:22,代码来源:test_flask_requests.py

示例6: test_multiple_values

# 需要导入模块: from werkzeug import datastructures [as 别名]
# 或者: from werkzeug.datastructures import ImmutableMultiDict [as 别名]
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 
开发者ID:p1c2u,项目名称:openapi-core,代码行数:25,代码来源:test_flask_requests.py

示例7: test_simple

# 需要导入模块: from werkzeug import datastructures [as 别名]
# 或者: from werkzeug.datastructures import ImmutableMultiDict [as 别名]
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' 
开发者ID:p1c2u,项目名称:openapi-core,代码行数:21,代码来源:test_requests_requests.py

示例8: test_multiple_values

# 需要导入模块: from werkzeug import datastructures [as 别名]
# 或者: from werkzeug.datastructures import ImmutableMultiDict [as 别名]
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' 
开发者ID:p1c2u,项目名称:openapi-core,代码行数:24,代码来源:test_requests_requests.py

示例9: test_url_rule

# 需要导入模块: from werkzeug import datastructures [as 别名]
# 或者: from werkzeug.datastructures import ImmutableMultiDict [as 别名]
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' 
开发者ID:p1c2u,项目名称:openapi-core,代码行数:23,代码来源:test_requests_requests.py

示例10: store_conf_srv

# 需要导入模块: from werkzeug import datastructures [as 别名]
# 或者: from werkzeug.datastructures import ImmutableMultiDict [as 别名]
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)) 
开发者ID:ziirish,项目名称:burp-ui,代码行数:23,代码来源:multi.py

示例11: test_or_logic

# 需要导入模块: from werkzeug import datastructures [as 别名]
# 或者: from werkzeug.datastructures import ImmutableMultiDict [as 别名]
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)) 
开发者ID:accelero-cloud,项目名称:appkernel,代码行数:18,代码来源:request_processor_test.py

示例12: define_device

# 需要导入模块: from werkzeug import datastructures [as 别名]
# 或者: from werkzeug.datastructures import ImmutableMultiDict [as 别名]
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"),
        ]
    ) 
开发者ID:eNMS-automation,项目名称:eNMS,代码行数:18,代码来源:test_inventory.py

示例13: make_fake_dashboard

# 需要导入模块: from werkzeug import datastructures [as 别名]
# 或者: from werkzeug.datastructures import ImmutableMultiDict [as 别名]
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',
    ) 
开发者ID:christabor,项目名称:flask_jsondash,代码行数:24,代码来源:model_factories.py

示例14: filter_by_args

# 需要导入模块: from werkzeug import datastructures [as 别名]
# 或者: from werkzeug.datastructures import ImmutableMultiDict [as 别名]
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 
开发者ID:kkamkou,项目名称:gitmostwanted.com,代码行数:20,代码来源:repo.py

示例15: authenticate

# 需要导入模块: from werkzeug import datastructures [as 别名]
# 或者: from werkzeug.datastructures import ImmutableMultiDict [as 别名]
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'])
        ) 
开发者ID:spoqa,项目名称:geofront,代码行数:36,代码来源:stash.py


注:本文中的werkzeug.datastructures.ImmutableMultiDict方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。