本文整理汇总了Python中safe.common.utilities.tr函数的典型用法代码示例。如果您正苦于以下问题:Python tr函数的具体用法?Python tr怎么用?Python tr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:essc,项目名称:inasafe,代码行数:35,代码来源:pager_earthquake_fatality_model.py
示例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
开发者ID:SamudraYe,项目名称:inasafe,代码行数:35,代码来源:flood_population_evacuation_polygon_hazard.py
示例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)
开发者ID:lptorres,项目名称:webandgis,代码行数:28,代码来源:aggregation_postprocessor.py
示例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
开发者ID:cccs-ip,项目名称:inasafe,代码行数:35,代码来源:categorised_hazard_population.py
示例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)
开发者ID:lptorres,项目名称:inasafe,代码行数:32,代码来源:building_type_postprocessor.py
示例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
开发者ID:SamudraYe,项目名称:inasafe,代码行数:35,代码来源:itb_earthquake_fatality_model.py
示例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
开发者ID:cccs-ip,项目名称:inasafe,代码行数:33,代码来源:flood_building_impact_qgis.py
示例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
开发者ID:CharlesRethman,项目名称:inasafe,代码行数:59,代码来源:core.py
示例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
开发者ID:cccs-ip,项目名称:inasafe,代码行数:49,代码来源:flood_OSM_building_impact.py
示例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)
开发者ID:dichapabe,项目名称:inasafe,代码行数:30,代码来源:gender_postprocessor.py
示例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.')
开发者ID:D2KG,项目名称:FLOOgin,代码行数:7,代码来源:building_type_postprocessor.py
示例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)
开发者ID:D2KG,项目名称:FLOOgin,代码行数:16,代码来源:building_type_postprocessor.py
示例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)
开发者ID:dichapabe,项目名称:inasafe,代码行数:25,代码来源:gender_postprocessor.py
示例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)
开发者ID:rendyhermawan,项目名称:inasafe,代码行数:25,代码来源:gender_postprocessor.py
示例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)
开发者ID:lptorres,项目名称:noah-inasafe,代码行数:26,代码来源:aggregation_categorical_postprocessor.py
示例16: _calculate_adult
def _calculate_adult(self):
"""Indicator that shows population between 15 and 64 years old.
this indicator reports the amount of young population according to the
set adult_ratio
Args:
None
Returns:
None
Raises:
None
"""
myName = tr('Adult count')
#FIXME (MB) Shameless hack to deal with issue #368
if self.population_total > 8000000000 or self.population_total < 0:
self._append_result(myName, self.NO_DATA_TEXT)
return
myResult = self.population_total * self.adult_ratio
try:
myResult = int(round(myResult))
except ValueError:
myResult = self.NO_DATA_TEXT
self._append_result(myName, myResult)
开发者ID:simod,项目名称:inasafe,代码行数:26,代码来源:age_postprocessor.py
示例17: _calculate_weekly_increased_calories
def _calculate_weekly_increased_calories(self):
"""Weekly additional kg of rice for pregnant and lactating women
indicator.
This indicator reports the weekly additional kg of rice for pregnant
and lactating women.
for further detail refer to the "Sample InaSAFE Actions for Vulnerable
Populations" [27.07.2012] paper
Args:
None
Returns:
None
Raises:
None
"""
myName = tr('Additional weekly rice kg for pregnant and lactating'
' women')
myMeta = {'description': 'Additional rice kg per week for pregnant and'
' lactating women'}
#weekly Kg rice =
# affected pop * fem_ratio * 0.7937 * week / intended day-of-use
myLactKg = self.impact_total * self.female_ratio * 2 * 0.033782
myPregKg = self.impact_total * self.female_ratio * 2 * 0.01281
myResult = myLactKg + myPregKg
try:
myResult = int(round(myResult))
except ValueError:
myResult = self.NO_DATA_TEXT
self._append_result(myName, myResult, myMeta)
开发者ID:meymeynard,项目名称:angularsafe,代码行数:31,代码来源:gender_postprocessor.py
示例18: _calculate_elderly
def _calculate_elderly(self):
"""Indicator that shows population above 64 years old.
this indicator reports the amount of young population according to the
set elderly_ratio
Args:
None
Returns:
None
Raises:
None
"""
myName = tr('Elderly count (affected)')
#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 * self.elderly_ratio
try:
myResult = int(round(myResult))
except ValueError:
myResult = self.NO_DATA_TEXT
self._append_result(myName, myResult)
开发者ID:mook-worldbank,项目名称:inasafe,代码行数:26,代码来源:age_postprocessor.py
示例19: _calculate_females
def _calculate_females(self):
"""Female population count indicator.
this indicator reports the amount of female population according to the
set female_ratio
Args:
None
Returns:
None
Raises:
None
"""
myName = tr('Female population (affected)')
#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 * self.female_ratio
try:
myResult = int(round(myResult))
except ValueError:
myResult = self.NO_DATA_TEXT
self._append_result(myName, myResult)
开发者ID:dichapabe,项目名称:inasafe,代码行数:26,代码来源:gender_postprocessor.py
示例20: default_minimum_needs
def default_minimum_needs():
"""Helper to get the default minimum needs.
.. note:: Key names will be translated.
"""
rice = tr('Rice')
drinking_water = tr('Drinking Water')
water = tr('Water')
family_kits = tr('Family Kits')
toilets = tr('Toilets')
minimum_needs = OrderedDict([
(rice, 2.8),
(drinking_water, 17.5),
(water, 105),
(family_kits, 0.2),
(toilets, 0.05)])
return minimum_needs
开发者ID:lptorres,项目名称:webandgis,代码行数:17,代码来源:core.py
注:本文中的safe.common.utilities.tr函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论