本文整理汇总了Python中treemap.models.Species.get_itree_code方法的典型用法代码示例。如果您正苦于以下问题:Python Species.get_itree_code方法的具体用法?Python Species.get_itree_code怎么用?Python Species.get_itree_code使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类treemap.models.Species
的用法示例。
在下文中一共展示了Species.get_itree_code方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: commit_row
# 需要导入模块: from treemap.models import Species [as 别名]
# 或者: from treemap.models.Species import get_itree_code [as 别名]
def commit_row(self):
is_valid = self.validate_row()
if not is_valid or not self.merged:
return # not ready to commit
if self.status == SpeciesImportRow.SUCCESS:
return # nothing changed so no need to commit
# Get our data
data = self.cleaned
species_edited = False
# Initially grab species from row if it exists and edit it
species = self.species
# If not specified create a new one
if species is None:
species = Species(instance=self.import_event.instance)
# Convert units
self.convert_units(data, {
fields.species.MAX_DIAMETER:
self.import_event.max_diameter_conversion_factor,
fields.species.MAX_HEIGHT:
self.import_event.max_tree_height_conversion_factor
})
for modelkey, datakey in SpeciesImportRow.SPECIES_MAP.iteritems():
importdata = data.get(datakey, None)
if importdata is not None:
species_edited = True
setattr(species, modelkey, importdata)
# Set OTM code if missing and available
if not species.otm_code:
species_dict = species_for_scientific_name(
species.genus, species.species, species.cultivar,
species.other_part_of_name)
if species_dict:
species_edited = True
species.otm_code = species_dict['otm_code']
if species_edited:
species.save_with_system_user_bypass_auth()
# Make i-Tree code override(s) if necessary
if fields.species.ITREE_PAIRS in data:
for region_code, itree_code in data[fields.species.ITREE_PAIRS]:
if itree_code != species.get_itree_code(region_code):
override = ITreeCodeOverride.objects.get_or_create(
instance_species=species,
region=ITreeRegion.objects.get(code=region_code),
)[0]
override.itree_code = itree_code
override.save_with_user(User.system_user())
self.species = species
self.status = SpeciesImportRow.SUCCESS
self.save()