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


Python collections_abc.Mapping方法代码示例

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


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

示例1: from_api_repr

# 需要导入模块: from six.moves import collections_abc [as 别名]
# 或者: from six.moves.collections_abc import Mapping [as 别名]
def from_api_repr(cls, api_repr):
        """Return a ``SchemaField`` object deserialized from a dictionary.

        Args:
            api_repr (Mapping[str, str]): The serialized representation
                of the SchemaField, such as what is output by
                :meth:`to_api_repr`.

        Returns:
            google.cloud.biquery.schema.SchemaField: The ``SchemaField`` object.
        """
        # Handle optional properties with default values
        mode = api_repr.get("mode", "NULLABLE")
        description = api_repr.get("description")
        fields = api_repr.get("fields", ())

        return cls(
            field_type=api_repr["type"].upper(),
            fields=[cls.from_api_repr(f) for f in fields],
            mode=mode.upper(),
            description=description,
            name=api_repr["name"],
            policy_tags=PolicyTagList.from_api_repr(api_repr.get("policyTags")),
        ) 
开发者ID:googleapis,项目名称:python-bigquery,代码行数:26,代码来源:schema.py

示例2: _parse_schema_resource

# 需要导入模块: from six.moves import collections_abc [as 别名]
# 或者: from six.moves.collections_abc import Mapping [as 别名]
def _parse_schema_resource(info):
    """Parse a resource fragment into a schema field.

    Args:
        info: (Mapping[str, Dict]): should contain a "fields" key to be parsed

    Returns:
        Optional[Sequence[google.cloud.bigquery.schema.SchemaField`]:
            A list of parsed fields, or ``None`` if no "fields" key found.
    """
    if "fields" not in info:
        return ()

    schema = []
    for r_field in info["fields"]:
        name = r_field["name"]
        field_type = r_field["type"]
        mode = r_field.get("mode", "NULLABLE")
        description = r_field.get("description")
        sub_fields = _parse_schema_resource(r_field)
        policy_tags = PolicyTagList.from_api_repr(r_field.get("policyTags"))
        schema.append(
            SchemaField(name, field_type, mode, description, sub_fields, policy_tags)
        )
    return schema 
开发者ID:googleapis,项目名称:python-bigquery,代码行数:27,代码来源:schema.py

示例3: is_unordered_dict

# 需要导入模块: from six.moves import collections_abc [as 别名]
# 或者: from six.moves.collections_abc import Mapping [as 别名]
def is_unordered_dict(self, subject):
        if isinstance(subject, collections_abc.Mapping):
            if not hasattr(collections, 'OrderedDict'):
                return True
            return not isinstance(subject, collections.OrderedDict)
        return False 
开发者ID:grappa-py,项目名称:grappa,代码行数:8,代码来源:start_end.py

示例4: _not_a_dict

# 需要导入模块: from six.moves import collections_abc [as 别名]
# 或者: from six.moves.collections_abc import Mapping [as 别名]
def _not_a_dict(self, value):
        return not isinstance(value, collections_abc.Mapping) 
开发者ID:grappa-py,项目名称:grappa,代码行数:4,代码来源:keys.py

示例5: revoke

# 需要导入模块: from six.moves import collections_abc [as 别名]
# 或者: from six.moves.collections_abc import Mapping [as 别名]
def revoke(data):
    """Revoke a STIX object.

    Returns:
        A new version of the object with ``revoked`` set to ``True``.
    """
    if not isinstance(data, Mapping):
        raise ValueError(
            "cannot revoke object of this type! Try a dictionary "
            "or instance of an SDO or SRO class.",
        )

    if data.get('revoked'):
        raise RevokeError("revoke")
    return new_version(data, revoked=True) 
开发者ID:oasis-open,项目名称:cti-python-stix2,代码行数:17,代码来源:versioning.py

示例6: _to_schema_fields

# 需要导入模块: from six.moves import collections_abc [as 别名]
# 或者: from six.moves.collections_abc import Mapping [as 别名]
def _to_schema_fields(schema):
    """Coerce `schema` to a list of schema field instances.

    Args:
        schema(Sequence[Union[ \
            :class:`~google.cloud.bigquery.schema.SchemaField`, \
            Mapping[str, Any] \
        ]]):
            Table schema to convert. If some items are passed as mappings,
            their content must be compatible with
            :meth:`~google.cloud.bigquery.schema.SchemaField.from_api_repr`.

    Returns:
        Sequence[:class:`~google.cloud.bigquery.schema.SchemaField`]

    Raises:
        Exception: If ``schema`` is not a sequence, or if any item in the
        sequence is not a :class:`~google.cloud.bigquery.schema.SchemaField`
        instance or a compatible mapping representation of the field.
    """
    for field in schema:
        if not isinstance(field, (SchemaField, collections_abc.Mapping)):
            raise ValueError(
                "Schema items must either be fields or compatible "
                "mapping representations."
            )

    return [
        field if isinstance(field, SchemaField) else SchemaField.from_api_repr(field)
        for field in schema
    ] 
开发者ID:googleapis,项目名称:python-bigquery,代码行数:33,代码来源:schema.py


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