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


Python types.MappingProxyType方法代码示例

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


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

示例1: validate_query

# 需要导入模块: import types [as 别名]
# 或者: from types import MappingProxyType [as 别名]
def validate_query(query, possible_columns):
    q = validate_query_structure(query)
    sort_field = q.get('_sortField')

    filters = q.get('_filters', [])
    columns = [field_name for field_name in filters]

    if sort_field is not None:
        columns.append(sort_field)

    not_valid = set(columns).difference(
        possible_columns + [MULTI_FIELD_TEXT_QUERY])
    if not_valid:
        column_list = ', '.join(not_valid)
        msg = 'Columns: {} do not present in resource'.format(column_list)
        raise JsonValidaitonError(msg)
    return MappingProxyType(q) 
开发者ID:aio-libs,项目名称:aiohttp_admin,代码行数:19,代码来源:utils.py

示例2: _make_context_immutable

# 需要导入模块: import types [as 别名]
# 或者: from types import MappingProxyType [as 别名]
def _make_context_immutable(context):
    """Best effort attempt at turning a properly formatted context
    (either a string, dict, or array of strings and dicts) into an
    immutable data structure.

    If we get an array, make it immutable by creating a tuple; if we get
    a dict, copy it into a MappingProxyType. Otherwise, return as-is.
    """
    def make_immutable(val):
        if isinstance(val, Mapping):
            return MappingProxyType(val)
        else:
            return val

    if not isinstance(context, (str, Mapping)):
        try:
            return tuple([make_immutable(val) for val in context])
        except TypeError:
            pass
    return make_immutable(context) 
开发者ID:COALAIP,项目名称:pycoalaip,代码行数:22,代码来源:data_formats.py

示例3: __init_subclass__

# 需要导入模块: import types [as 别名]
# 或者: from types import MappingProxyType [as 别名]
def __init_subclass__(cls):
        if not hasattr(cls, 'states'):
            return

        re_states = {}
        for state, rules in cls.states.items():
            res = []
            for rule in rules:
                if cls.asbytes:
                    res.append(b'(?P<%b>%b)' % (rule.id.encode(), rule.regexp))
                else:
                    res.append('(?P<{}>{})'.format(rule.id, rule.regexp))

            if cls.asbytes:
                res.append(b'(?P<err>.)')
            else:
                res.append('(?P<err>.)')

            if cls.asbytes:
                full_re = b' | '.join(res)
            else:
                full_re = ' | '.join(res)
            re_states[state] = re.compile(full_re, cls.RE_FLAGS)

        cls.re_states = types.MappingProxyType(re_states) 
开发者ID:edgedb,项目名称:edgedb,代码行数:27,代码来源:lexer.py

示例4: lint

# 需要导入模块: import types [as 别名]
# 或者: from types import MappingProxyType [as 别名]
def lint(gdscript_code: str, config: MappingProxyType) -> List[Problem]:
    disable = config["disable"]
    checks_to_run_w_code = [
        (
            "max-line-length",
            partial(_max_line_length_check, config["max-line-length"]),
        ),
        ("max-file-lines", partial(_max_file_lines_check, config["max-file-lines"]),),
        ("trailing-whitespace", _trailing_ws_check,),
        ("mixed-tabs-and-spaces", _mixed_tabs_and_spaces_check,),
    ]  # type: List[Tuple[str, Callable]]
    problem_clusters = map(
        lambda x: x[1](gdscript_code) if x[0] not in disable else [],
        checks_to_run_w_code,
    )
    problems = [problem for cluster in problem_clusters for problem in cluster]
    return problems 
开发者ID:Scony,项目名称:godot-gdscript-toolkit,代码行数:19,代码来源:format_checks.py

示例5: write_sparse_as_dense

# 需要导入模块: import types [as 别名]
# 或者: from types import MappingProxyType [as 别名]
def write_sparse_as_dense(f, key, value, dataset_kwargs=MappingProxyType({})):
    real_key = None  # Flag for if temporary key was used
    if key in f:
        if (
            isinstance(value, (h5py.Group, h5py.Dataset, SparseDataset))
            and value.file.filename == f.filename
        ):  # Write to temporary key before overwriting
            real_key = key
            # Transform key to temporary, e.g. raw/X -> raw/_X, or X -> _X
            key = re.sub(r"(.*)(\w(?!.*/))", r"\1_\2", key.rstrip("/"))
        else:
            del f[key]  # Wipe before write
    dset = f.create_dataset(key, shape=value.shape, dtype=value.dtype, **dataset_kwargs)
    compressed_axis = int(isinstance(value, sparse.csc_matrix))
    for idx in idx_chunks_along_axis(value.shape, compressed_axis, 1000):
        dset[idx] = value[idx].toarray()
    if real_key is not None:
        del f[real_key]
        f[real_key] = f[key]
        del f[key] 
开发者ID:theislab,项目名称:anndata,代码行数:22,代码来源:h5ad.py

示例6: save_mappingproxy

# 需要导入模块: import types [as 别名]
# 或者: from types import MappingProxyType [as 别名]
def save_mappingproxy(self, obj):
            self.save_reduce(types.MappingProxyType, (dict(obj),), obj=obj) 
开发者ID:pywren,项目名称:pywren-ibm-cloud,代码行数:4,代码来源:cloudpickle.py

示例7: __init__

# 需要导入模块: import types [as 别名]
# 或者: from types import MappingProxyType [as 别名]
def __init__(self, parameters=None, *, return_annotation=_empty,
                 __validate_parameters__=True):
        '''Constructs Signature from the given list of Parameter
        objects and 'return_annotation'.  All arguments are optional.
        '''

        if parameters is None:
            params = OrderedDict()
        else:
            if __validate_parameters__:
                params = OrderedDict()
                top_kind = _POSITIONAL_ONLY

                for idx, param in enumerate(parameters):
                    kind = param.kind
                    if kind < top_kind:
                        msg = 'wrong parameter order: {} before {}'
                        msg = msg.format(top_kind, param.kind)
                        raise ValueError(msg)
                    else:
                        top_kind = kind

                    name = param.name
                    if name is None:
                        name = str(idx)
                        param = param.replace(name=name)

                    if name in params:
                        msg = 'duplicate parameter name: {!r}'.format(name)
                        raise ValueError(msg)
                    params[name] = param
            else:
                params = OrderedDict(((param.name, param)
                                                for param in parameters))

        self._parameters = types.MappingProxyType(params)
        self._return_annotation = return_annotation 
开发者ID:war-and-code,项目名称:jawfish,代码行数:39,代码来源:inspect.py

示例8: parameters

# 需要导入模块: import types [as 别名]
# 或者: from types import MappingProxyType [as 别名]
def parameters(self):
    try:
      return types.MappingProxyType(self._parameters)
    except AttributeError:
      return OrderedDict(self._parameters.items()) 
开发者ID:google,项目名称:tangent,代码行数:7,代码来源:funcsigs.py

示例9: _match_key_mapping

# 需要导入模块: import types [as 别名]
# 或者: from types import MappingProxyType [as 别名]
def _match_key_mapping(
            self, sequence: keyutils.KeySequence) -> MatchResult:
        """Try to match a key in bindings.key_mappings."""
        self._debug_log("Trying match with key_mappings")
        mapped = sequence.with_mappings(
            types.MappingProxyType(config.cache['bindings.key_mappings']))
        if sequence != mapped:
            self._debug_log("Mapped {} -> {}".format(
                sequence, mapped))
            return self._match_key(mapped)
        return MatchResult(match_type=QKeySequence.NoMatch,
                           command=None,
                           sequence=sequence) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:15,代码来源:basekeyparser.py

示例10: pubsub_channels

# 需要导入模块: import types [as 别名]
# 或者: from types import MappingProxyType [as 别名]
def pubsub_channels(self):
        """Returns read-only channels dict."""
        return types.MappingProxyType(self._pubsub_channels) 
开发者ID:aio-libs,项目名称:aioredis,代码行数:5,代码来源:connection.py

示例11: pubsub_patterns

# 需要导入模块: import types [as 别名]
# 或者: from types import MappingProxyType [as 别名]
def pubsub_patterns(self):
        """Returns read-only patterns dict."""
        return types.MappingProxyType(self._pubsub_patterns) 
开发者ID:aio-libs,项目名称:aioredis,代码行数:5,代码来源:connection.py

示例12: channels

# 需要导入模块: import types [as 别名]
# 或者: from types import MappingProxyType [as 别名]
def channels(self):
        """Read-only channels dict."""
        return types.MappingProxyType({
            ch.name: ch for ch in self._refs.values()
            if not ch.is_pattern}) 
开发者ID:aio-libs,项目名称:aioredis,代码行数:7,代码来源:pubsub.py

示例13: patterns

# 需要导入模块: import types [as 别名]
# 或者: from types import MappingProxyType [as 别名]
def patterns(self):
        """Read-only patterns dict."""
        return types.MappingProxyType({
            ch.name: ch for ch in self._refs.values()
            if ch.is_pattern}) 
开发者ID:aio-libs,项目名称:aioredis,代码行数:7,代码来源:pubsub.py

示例14: pubsub_channels

# 需要导入模块: import types [as 别名]
# 或者: from types import MappingProxyType [as 别名]
def pubsub_channels(self):
        if self._pubsub_conn and not self._pubsub_conn.closed:
            return self._pubsub_conn.pubsub_channels
        return types.MappingProxyType({}) 
开发者ID:aio-libs,项目名称:aioredis,代码行数:6,代码来源:pool.py

示例15: __init_subclass__

# 需要导入模块: import types [as 别名]
# 或者: from types import MappingProxyType [as 别名]
def __init_subclass__(cls, **kwargs):
        super().__init_subclass__(**kwargs)

        if not hasattr(cls, "__schema_name__"):
            raise TypeError("Entity type does not have a schema name")

        schema_name = getattr(cls, "__schema_name__")
        cls.subclasses[schema_name] = cls

        # Handle base case (Entity)
        if not schema_name:
            return

        # Set properties on metaclass by fetching from schema
        (schema_props, validators, defaults, display_map) = get_schema_details(
            schema_name
        )

        # Set validator dict on metaclass for each prop.
        # To be used during __setattr__() to validate props.
        # Look at validate() for details.
        setattr(cls, "__validator_dict__", MappingProxyType(validators))

        # Set defaults which will be used during serialization.
        # Look at json_dumps() for details
        setattr(cls, "__default_attrs__", MappingProxyType(defaults))

        # Attach schema properties to metaclass
        setattr(cls, "__schema_props__", MappingProxyType(schema_props))

        # Attach display map for compile/decompile
        setattr(cls, "__display_map__", MappingProxyType(display_map)) 
开发者ID:nutanix,项目名称:calm-dsl,代码行数:34,代码来源:entity.py


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