本文整理汇总了Python中safe.common.utilities.is_key_exist函数的典型用法代码示例。如果您正苦于以下问题:Python is_key_exist函数的具体用法?Python is_key_exist怎么用?Python is_key_exist使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_key_exist函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: exposure_additional_keywords
def exposure_additional_keywords(
cls, layer_mode_key=None, layer_geometry_key=None,
exposure_key=None):
"""Return additional_keywords for exposure.
:param layer_mode_key: The layer mode key
:type layer_mode_key: str
:param layer_geometry_key: The layer geometry key
:type layer_geometry_key: str
:param exposure_key: The hazard key
:type exposure_key: str
:returns: List of additional keywords
:rtype: list
"""
exposure_layer_req = cls.get_exposure_requirements()
layer_mode = exposure_layer_req['layer_mode']
layer_geometries = exposure_layer_req['layer_geometries']
exposures = exposure_layer_req['exposure_types']
if layer_mode_key:
if layer_mode_key != layer_mode['key']:
return []
if layer_geometry_key:
if not is_key_exist(layer_geometry_key, layer_geometries):
return []
if exposure_key:
if not is_key_exist(exposure_key, exposures):
return []
additional_keywords = exposure_layer_req['additional_keywords']
return additional_keywords
示例2: exposure_class_fields
def exposure_class_fields(
cls, layer_mode_key=None, layer_geometry_key=None,
exposure_key=None):
"""Return list of exposure class field.
:param layer_mode_key: The layer mode key
:type layer_mode_key: str
:param layer_geometry_key: The layer geometry key
:type layer_geometry_key: str
:param exposure_key: The exposure key
:type exposure_key: str
:returns: List of exposure class field.
:rtype: list
"""
exposure_layer_req = cls.get_exposure_requirements()
layer_mode = exposure_layer_req['layer_mode']
layer_geometries = exposure_layer_req['layer_geometries']
exposures = exposure_layer_req['exposure_types']
if layer_mode_key:
if layer_mode_key != layer_mode['key']:
return []
if layer_geometry_key:
if not is_key_exist(layer_geometry_key, layer_geometries):
return []
if exposure_key:
if not is_key_exist(exposure_key, exposures):
return []
result = exposure_layer_req['exposure_class_fields']
return result
示例3: available_exposure_layer_mode
def available_exposure_layer_mode(
cls, exposure_key, exposure_geometry_key):
"""Get exposure layer mode for exposure_key.
:param exposure_key: The exposure key
:type exposure_key: str
:param exposure_geometry_key: The exposure geometry key
:type exposure_geometry_key: str
:returns: A layer mode
:rtype: dict
"""
exposure_layer_req = cls.get_exposure_requirements()
exposures = exposure_layer_req['exposure_types']
exposure_geometries = exposure_layer_req['layer_geometries']
if not is_key_exist(exposure_key, exposures):
return None
if not is_key_exist(exposure_geometry_key, exposure_geometries):
return None
layer_mode = exposure_layer_req['layer_mode']
return layer_mode
示例4: available_hazard_layer_mode
def available_hazard_layer_mode(
cls, hazard_key, hazard_geometry_key, hazard_category_key):
"""Return all available layer_mode.
:param hazard_key: The hazard key
:type hazard_key: str
:param hazard_geometry_key: The hazard geometry key
:type hazard_geometry_key: str
:param hazard_category_key: The hazard category key
:type hazard_category_key: str
:returns: A layer mode
:rtype: dict, None
"""
hazard_layer_req = cls.get_hazard_requirements()
hazards = hazard_layer_req['hazard_types']
hazard_categories = hazard_layer_req['hazard_categories']
hazard_geometries = hazard_layer_req['layer_geometries']
if not is_key_exist(hazard_key, hazards):
return None
if not is_key_exist(hazard_geometry_key, hazard_geometries):
return None
if not is_key_exist(hazard_category_key, hazard_categories):
return None
layer_mode = hazard_layer_req['layer_mode']
return layer_mode
示例5: available_hazard_constraints
def available_hazard_constraints(cls, hazard_key, hazard_category_key):
"""Get hazard constraints for hazard_key and hazard_category_key
:param hazard_key: The hazard key
:type hazard_key: str
:param hazard_category_key: The hazard category key
:type hazard_category_key: str
:returns: List of tuple of layer_mode and layer_geometry
:rtype: list
"""
hazard_layer_req = cls.get_hazard_requirements()
hazards = hazard_layer_req['hazard_types']
hazard_categories = hazard_layer_req['hazard_categories']
if not is_key_exist(hazard_key, hazards):
return []
if not is_key_exist(hazard_category_key, hazard_categories):
return []
layer_mode = hazard_layer_req['layer_mode']
layer_geometries = hazard_layer_req['layer_geometries']
result = []
for layer_geometry in layer_geometries:
result.append((layer_mode, layer_geometry))
return result
示例6: is_function_for_constraint
def is_function_for_constraint(
cls,
hazard_key,
exposure_key,
hazard_geometry_key=None,
exposure_geometry_key=None,
hazard_mode_key=None,
exposure_mode_key=None,
):
"""Check if the constraints match with the function.
:param hazard_key: The hazard key
:type hazard_key: str
:param exposure_key: the exposure key
:type exposure_key: str
:param hazard_geometry_key: The hazard geometry key
:type hazard_geometry_key: str
:param exposure_geometry_key: The exposure geometry key
:type exposure_geometry_key: str
:param hazard_mode_key: The hazard mode key
:type hazard_mode_key: str
:param exposure_mode_key: The exposure mode key
:type exposure_mode_key: str
:returns: True if match, else False
:rtype: bool
"""
hazard_layer_req = cls.get_hazard_requirements()
exposure_layer_req = cls.get_exposure_requirements()
hazards = hazard_layer_req["hazard_types"]
exposures = exposure_layer_req["exposure_types"]
hazard_geometries = hazard_layer_req["layer_geometries"]
exposure_geometries = exposure_layer_req["layer_geometries"]
hazard_mode = hazard_layer_req["layer_mode"]
exposure_mode = exposure_layer_req["layer_mode"]
if not is_key_exist(hazard_key, hazards):
return False
if not is_key_exist(exposure_key, exposures):
return False
if hazard_geometry_key:
if not is_key_exist(hazard_geometry_key, hazard_geometries):
return False
if exposure_geometry_key:
if not is_key_exist(exposure_geometry_key, exposure_geometries):
return False
if hazard_mode_key:
if hazard_mode_key != hazard_mode["key"]:
return False
if exposure_mode_key:
if exposure_mode_key != exposure_mode["key"]:
return False
return True
示例7: hazard_additional_keywords
def hazard_additional_keywords(
cls, layer_mode_key=None, layer_geometry_key=None,
hazard_category_key=None, hazard_key=None):
"""Return additional_keywords for hazard.
:param layer_mode_key: The layer mode key
:type layer_mode_key: str
:param layer_geometry_key: The layer geometry key
:type layer_geometry_key: str
:param hazard_category_key: The hazard category key
:type hazard_category_key: str
:param hazard_key: The hazard key
:type hazard_key: str
:returns: List of additional keywords
:rtype: list
"""
hazard_layer_req = cls.get_hazard_requirements()
layer_mode = hazard_layer_req['layer_mode']
layer_geometries = hazard_layer_req['layer_geometries']
hazard_categories = hazard_layer_req['hazard_categories']
hazards = hazard_layer_req['hazard_types']
if layer_mode_key:
if layer_mode_key != layer_mode['key']:
return []
if layer_geometry_key:
if not is_key_exist(layer_geometry_key, layer_geometries):
return []
if hazard_category_key:
if not is_key_exist(hazard_category_key, hazard_categories):
return []
if hazard_key:
if not is_key_exist(hazard_key, hazards):
return []
additional_keywords = hazard_layer_req['additional_keywords']
return additional_keywords
示例8: hazards_for_layer
def hazards_for_layer(cls, hazard_geometry_key, hazard_category_key=None):
"""Get hazard categories form layer_geometry_key
:param hazard_geometry_key: The geometry id
:type hazard_geometry_key: str
:param hazard_category_key: The hazard category
:type hazard_category_key: str
:returns: List of hazard
:rtype: list
"""
hazard_layer_req = cls.get_hazard_requirements()
hazard_categories = hazard_layer_req['hazard_categories']
hazard_geometries = hazard_layer_req['layer_geometries']
if not is_key_exist(hazard_geometry_key, hazard_geometries):
return []
if hazard_category_key:
if not is_key_exist(hazard_category_key, hazard_categories):
return []
return hazard_layer_req['hazard_types']
示例9: available_exposure_constraints
def available_exposure_constraints(cls, exposure_key):
"""Get exposure constraints for exposure_key.
:param exposure_key: The exposure key
:type exposure_key: str
:returns: List of tuple of layer_mode and layer_geometry
:rtype: list
"""
exposure_layer_req = cls.get_exposure_requirements()
exposures = exposure_layer_req['exposure_types']
if not is_key_exist(exposure_key, exposures):
return []
layer_mode = exposure_layer_req['layer_mode']
layer_geometries = exposure_layer_req['layer_geometries']
result = []
for layer_geometry in layer_geometries:
result.append((layer_mode, layer_geometry))
return result