def assemble_name( self, genus, subgenus, specific_epithet, verbatim_taxon_rank, taxon_rank, infraspecific_epithet ): if not has_content(genus): raise Exception('SciNameAssembler requires value for ' + self._genus_field_name) if not has_content(infraspecific_epithet) and not has_content(specific_epithet): raise Exception('SciNameAssembler requires values for ' + _specific_epithet_field_name + ' if ' + _infraspecific_epithet_field_name + ' provided') return str(SpacedStringBuilder() .append(genus) .append(subgenus) .append(specific_epithet) .append(verbatim_taxon_rank if has_content(verbatim_taxon_rank) else taxon_rank) .append(infraspecific_epithet) )
def assemble_name(self, genus, subgenus, specific_epithet, verbatim_taxon_rank, taxon_rank, infraspecific_epithet): if not has_content(genus): raise Exception('SciNameAssembler requires value for ' + self._genus_field_name) if not has_content(infraspecific_epithet) and not has_content( specific_epithet): raise Exception('SciNameAssembler requires values for ' + _specific_epithet_field_name + ' if ' + _infraspecific_epithet_field_name + ' provided') return str(SpacedStringBuilder().append(genus).append(subgenus).append( specific_epithet).append(verbatim_taxon_rank if has_content( verbatim_taxon_rank) else taxon_rank).append( infraspecific_epithet))
def test_has_content_returns_true_for_text_with_trimmable_whitespace(self): self.assertTrue(has_content(' some text '))
def test_has_content_returns_true_for_one_nonwhitespace_char_with_whitespace(self): self.assertTrue(has_content(' n '))
def test_has_content_returns_false_for_multiple_spaces(self): self.assertFalse(has_content(' '))
def test_has_content_returns_false_for_one_space(self): self.assertFalse(has_content(' '))
def test_has_content_returns_false_for_empty_string(self): self.assertFalse(has_content(''))
def test_has_content_returns_false_for_none(self): self.assertFalse(has_content(None))