diff --git a/src/esx/esx_vi_generator.py b/src/esx/esx_vi_generator.py index 95521fa1e52b9edcdf0505739c1daf63daa1eb39..df913d89150cf731bb122a65623566f298b67adc 100755 --- a/src/esx/esx_vi_generator.py +++ b/src/esx/esx_vi_generator.py @@ -75,16 +75,17 @@ class Member: def get_occurrence_comment(self): - if self.occurrence == OCCURRENCE__REQUIRED_ITEM: - return "/* required */" - elif self.occurrence == OCCURRENCE__REQUIRED_LIST: - return "/* required, list */" - elif self.occurrence == OCCURRENCE__OPTIONAL_ITEM: - return "/* optional */" - elif self.occurrence == OCCURRENCE__OPTIONAL_LIST: - return "/* optional, list */" + occurrence_map = { + OCCURRENCE__REQUIRED_ITEM: "/* required */", + OCCURRENCE__REQUIRED_LIST: "/* required, list */", + OCCURRENCE__OPTIONAL_ITEM: "/* optional */", + OCCURRENCE__OPTIONAL_LIST: "/* optional, list */" + } + try: + return occurrence_map[self.occurrence] + except KeyError: + raise ValueError("unknown occurrence value '%s'" % self.occurrence) - raise ValueError("unknown occurrence value '%s'" % self.occurrence)