本文整理汇总了Python中safe.common.utilities.tr函数的典型用法代码示例。如果您正苦于以下问题:Python tr函数的具体用法?Python tr怎么用?Python tr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_metadata
def get_metadata():
"""Return metadata as a dictionary.
This is a static method. You can use it to get the metadata in
dictionary format for an impact function.
:returns: A dictionary representing all the metadata for the
concrete impact function.
:rtype: dict
"""
dict_meta = {
'id': 'PAGFatalityFunction.',
'name': tr('PAG Fatality Function.'),
'impact': tr('Die or be displaced according Pager model'),
'author': 'Helen Crowley',
'date_implemented': 'N/A',
'overview': tr(
'To assess the impact of earthquake on population based '
'on Population Vulnerability Model Pager'),
'categories': {
'hazard': {
'definition': hazard_definition,
'subcategory': hazard_earthquake,
'units': [unit_mmi],
'layer_constraints': [layer_raster_numeric]
},
'exposure': {
'definition': exposure_definition,
'subcategory': exposure_population,
'units': [unit_people_per_pixel],
'layer_constraints': [layer_raster_numeric]
}
}
}
return dict_meta
示例2: get_metadata
def get_metadata():
"""Return metadata as a dictionary.
This is a static method. You can use it to get the metadata in
dictionary format for an impact function.
:returns: A dictionary representing all the metadata for the
concrete impact function.
:rtype: dict
"""
dict_meta = {
'id': 'FloodEvacuationFunctionVectorHazard',
'name': tr('Flood Evacuation Function Vector Hazard'),
'impact': tr('Need evacuation'),
'author': 'AIFDR',
'date_implemented': 'N/A',
'overview': tr(
'To assess the impacts of flood inundation '
'in vector format on population.'),
'categories': {
'hazard': {
'definition': hazard_definition,
'subcategory': [hazard_flood],
'units': unit_wetdry,
'layer_constraints': [layer_vector_polygon]
},
'exposure': {
'definition': exposure_definition,
'subcategory': exposure_population,
'units': [unit_people_per_pixel],
'layer_constraints': [layer_raster_numeric]
}
}
}
return dict_meta
示例3: _calculate_total
def _calculate_total(self):
"""Indicator that shows total population.
this indicator reports the total population
Args:
None
Returns:
None
Raises:
None
"""
myName = tr('Total')
if self.target_field is not None:
myName = '%s %s' % (myName, tr(self.target_field).lower())
#FIXME (MB) Shameless hack to deal with issue #368
if self.impact_total > 8000000000 or self.impact_total < 0:
self._append_result(myName, self.NO_DATA_TEXT)
return
myResult = self.impact_total
try:
myResult = int(round(myResult))
except ValueError:
myResult = self.NO_DATA_TEXT
self._append_result(myName, myResult)
示例4: get_metadata
def get_metadata():
"""Return metadata as a dictionary.
This is a static method. You can use it to get the metadata in
dictionary format for an impact function.
:returns: A dictionary representing all the metadata for the
concrete impact function.
:rtype: dict
"""
dict_meta = {
'id': 'CategorisedHazardPopulationImpactFunction',
'name': tr('Categorised Hazard Population Impact Function'),
'impact': tr('Be impacted'),
'author': 'AIFDR',
'date_implemented': 'N/A',
'overview': tr(
'To assess the impacts of categorized hazards in raster '
'format on population raster layer.'),
'categories': {
'hazard': {
'definition': hazard_definition,
'subcategory': hazard_all,
'units': [unit_normalised],
'layer_constraints': [layer_raster_numeric]
},
'exposure': {
'definition': exposure_definition,
'subcategory': exposure_population,
'units': [unit_people_per_pixel],
'layer_constraints': [layer_raster_numeric]
}
}
}
return dict_meta
示例5: _calculate_type
def _calculate_type(self, title, types):
"""Indicator that shows total population.
this indicator reports the total population
Args:
None
Returns:
None
Raises:
None
"""
myName = tr(title)
if self.target_field is not None:
myName = '%s %s' % (myName, tr(self.target_field).lower())
myResult = 0
if self.type_field is not None:
try:
for building in self.impact_attrs:
if building[self.type_field] in types:
myResult += building[self.target_field]
myResult = int(round(myResult))
except (ValueError, KeyError):
myResult = self.NO_DATA_TEXT
else:
if self.noFeatures:
myResult = 0
else:
myResult = self.NO_DATA_TEXT
self._append_result(myName, myResult)
示例6: get_metadata
def get_metadata():
"""Return metadata as a dictionary
This is a static method. You can use it to get the metadata in
dictionary format for an impact function.
:returns: A dictionary representing all the metadata for the
concrete impact function.
:rtype: dict
"""
dict_meta = {
'id': 'ITBFatalityFunction',
'name': tr('ITB Fatality Function'),
'impact': tr('Die or be displaced'),
'author': 'Hadi Ghasemi',
'date_implemented': 'N/A',
'overview': tr(
'To assess the impact of earthquake on population based '
'on earthquake model developed by ITB'),
'categories': {
'hazard': {
'definition': hazard_definition,
'subcategory': hazard_earthquake,
'units': [unit_mmi],
'layer_constraints': [layer_raster_numeric]
},
'exposure': {
'definition': exposure_definition,
'subcategory': exposure_population,
'units': [unit_people_per_pixel],
'layer_constraints': [layer_raster_numeric]
}
}
}
return dict_meta
示例7: get_metadata
def get_metadata():
"""Return metadata as a dictionary.
This is a static method. You can use it to get the metadata in
dictionary format for an impact function.
:returns: A dictionary representing all the metadata for the
concrete impact function.
:rtype: dict
"""
dict_meta = {
'id': 'FloodNativePolygonExperimentalFunction',
'name': tr('Flood Native Polygon Experimental Function'),
'impact': tr('Be-flooded'),
'author': 'Dmitry Kolesov',
'date_implemented': 'N/A',
'overview': tr('N/A'),
'categories': {
'hazard': {
'definition': hazard_definition,
'subcategory': [hazard_flood],
'units': unit_wetdry,
'layer_constraints': [layer_vector_polygon]
},
'exposure': {
'definition': exposure_definition,
'subcategory': exposure_structure,
'units': [unit_building_type_type],
'layer_constraints': [layer_vector_polygon]
}
}
}
return dict_meta
示例8: evacuated_population_weekly_needs
def evacuated_population_weekly_needs(population,
minimum_needs=False,
human_names=False):
"""Calculate estimated needs using BNPB Perka 7/2008 minimum bantuan.
:param population: The number of evacuated population.
:type: int, float
:param minimum_needs: Ratios to use when calculating minimum needs.
Defaults to perka 7 as described in assumptions below.
:type minimum_needs: dict
:returns: The weekly needs for the evacuated population.
:rtype: dict
Assumptions:
* 400g rice per person per day
* 2.5L drinking water per person per day
* 15L clean water per person per day
* assume 5 people per family (not in perka - 0.2 people per family)
* 20 people per toilet (0.05 per person)
"""
rice = tr('Rice')
drinking_water = tr('Drinking Water')
water = tr('Water')
family_kits = tr('Family Kits')
toilets = tr('Toilets')
if not minimum_needs:
minimum_needs = default_minimum_needs()
min_rice = minimum_needs[rice]
min_drinking_water = minimum_needs[drinking_water]
min_water = minimum_needs[water]
min_family_kits = minimum_needs[family_kits]
min_toilets = minimum_needs[toilets]
val_rice = int(ceil(population * min_rice))
val_drinking_water = int(ceil(population * min_drinking_water))
val_water = int(ceil(population * min_water))
val_family_kits = int(ceil(population * min_family_kits))
val_toilets = int(ceil(population * min_toilets))
if human_names:
weekly_needs = {
rice: val_rice,
drinking_water: val_drinking_water,
water: val_water,
family_kits: val_family_kits,
toilets: val_toilets}
else:
weekly_needs = {
'rice': val_rice,
'drinking_water': val_drinking_water,
'water': val_water,
'family_kits': val_family_kits,
'toilets': val_toilets}
return weekly_needs
示例9: get_metadata
def get_metadata():
"""Return metadata as a dictionary.
This is a static method. You can use it to get the metadata in
dictionary format for an impact function.
:returns: A dictionary representing all the metadata for the
concrete impact function.
:rtype: dict
"""
dict_meta = {
'id': 'FloodBuildingImpactFunction',
'name': tr('Flood Building Impact Function'),
'impact': tr('Be flooded'),
'author': ['Ole Nielsen', 'Kristy van Putten'],
'date_implemented': 'N/A',
'overview': tr(
'To assess the impacts of (flood or tsunami) inundation '
'on building footprints originating from OpenStreetMap '
'(OSM).'),
'categories': {
'hazard': {
'definition': hazard_definition,
'subcategory': [
hazard_flood,
hazard_tsunami
],
'units': [
unit_wetdry,
unit_metres_depth,
unit_feet_depth],
'layer_constraints': [
layer_vector_polygon,
layer_raster_numeric,
]
},
'exposure': {
'definition': exposure_definition,
'subcategory': exposure_structure,
'units': [
unit_building_type_type,
unit_building_generic],
'layer_constraints': [
layer_vector_polygon,
layer_vector_point]
}
}
}
return dict_meta
示例10: _calculate_weekly_hygene_packs
def _calculate_weekly_hygene_packs(self):
"""Weekly requirements of female hygiene packs indicator.
This indicator reports the weekly requirements of female hygiene packs
for further detail refer to the "Sample InaSAFE Actions for Vulnerable
Populations" [27.07.2012] paper
Args:
None
Returns:
None
Raises:
None
"""
myName = tr('Weekly hygiene packs')
myMeta = {'description': 'Females hygiene packs for weekly use'}
#FIXME (MB) Shameless hack to deal with issue #368
if self.impact_total > 8000000000 or self.impact_total < 0:
self._append_result(myName, self.NO_DATA_TEXT, myMeta)
return
#weekly hygene packs =
# affected pop * fem_ratio * 0.7937 * week / intended day-of-use
myResult = self.impact_total * self.female_ratio * 0.7937 * (7 / 7)
try:
myResult = int(round(myResult))
except ValueError:
myResult = self.NO_DATA_TEXT
self._append_result(myName, myResult, myMeta)
示例11: description
def description(self):
"""Describe briefly what the post processor does.
:returns: The translated description.
:rtype: str
"""
return tr('Calculates building types related statistics.')
示例12: _calculate_total
def _calculate_total(self):
"""Indicator that shows total population.
This indicator reports the total population.
"""
name = tr('Total')
if self.target_field is not None:
name = '%s %s' % (name, tr(self.target_field).lower())
result = self.impact_total
try:
result = int(round(result))
except ValueError:
result = self.NO_DATA_TEXT
self._append_result(name, result)
示例13: _calculate_total
def _calculate_total(self):
"""Total population indicator.
this indicator reports the total population
Args:
None
Returns:
None
Raises:
None
"""
myName = tr('Total')
#FIXME (MB) Shameless hack to deal with issue #368
if self.impact_total > 8000000000 or self.impact_total < 0:
self._append_result(myName, self.NO_DATA_TEXT)
return
try:
myResult = self.impact_total
myResult = int(round(myResult))
except ValueError:
myResult = self.NO_DATA_TEXT
self._append_result(myName, myResult)
示例14: _calculate_weekly_hygene_packs
def _calculate_weekly_hygene_packs(self):
"""Weekly requirements of female hygiene packs indicator.
This indicator reports the weekly requirements of female hygiene packs
for further detail refer to the "Sample InaSAFE Actions for Vulnerable
Populations" [27.07.2012] paper
Args:
None
Returns:
None
Raises:
None
"""
myName = tr("Weekly hygiene packs")
myMeta = {"description": "Females hygiene packs for weekly use"}
# weekly hygene packs =
# affected pop * fem_ratio * 0.7937 * week / intended day-of-use
myResult = self.impact_total * self.female_ratio * 0.7937 * (7 / 7)
try:
myResult = int(round(myResult))
except ValueError:
myResult = self.NO_DATA_TEXT
self._append_result(myName, myResult, myMeta)
示例15: _calculate_categories
def _calculate_categories(self):
"""Indicator that shows total population.
this indicator reports the total population
Args:
None
Returns:
None
Raises:
None
"""
impact_name = tr(self.target_field).lower()
results = {}
for impact_class in self.impact_classes:
results[impact_class] = 0
for feature in self.impact_attrs:
myTarget = feature[self.target_field]
results[myTarget] += 1
for impact_class in self.impact_classes:
result = results[impact_class]
self._append_result('%s %s' % (impact_name, impact_class), result)