Split the raising of the msd_to_properties error to more cases
This commit is contained in:
@@ -379,16 +379,20 @@ class Converter:
|
|||||||
category_char = msd.code[0].lower()
|
category_char = msd.code[0].lower()
|
||||||
value_chars = msd.code[1:]
|
value_chars = msd.code[1:]
|
||||||
category = self.specifications.find_category_by_code(category_char, msd.language)
|
category = self.specifications.find_category_by_code(category_char, msd.language)
|
||||||
|
if category is None:
|
||||||
|
raise MsdException(f"Msd '{msd.code}' cannot be converted to Properties: unknown category '{category_char}'.")
|
||||||
category_name = category.names.get(language)
|
category_name = category.names.get(language)
|
||||||
feature_value_list = []
|
feature_value_list = []
|
||||||
lexeme_feature_map = {}
|
lexeme_feature_map = {}
|
||||||
form_feature_map = {}
|
form_feature_map = {}
|
||||||
if msd.state not in [Msd.State.FULL, Msd.State.PARTIAL]:
|
|
||||||
raise MsdException(f"Msd must be full or partial to be converted to Properties, but is {msd.state.name}.")
|
|
||||||
for (index, value_char) in enumerate(value_chars, start=1):
|
for (index, value_char) in enumerate(value_chars, start=1):
|
||||||
if (value_char != '-'):
|
if (value_char != '-'):
|
||||||
feature = category.find_feature_by_position(index)
|
feature = category.find_feature_by_position(index)
|
||||||
|
if feature is None:
|
||||||
|
raise MsdException(f"Msd '{msd.code}' cannot be converted to Properties: no feature at position {index}.")
|
||||||
value = feature.find_value_by_char(value_char, msd.language)
|
value = feature.find_value_by_char(value_char, msd.language)
|
||||||
|
if value is None:
|
||||||
|
raise MsdException(f"Msd '{msd.code}' cannot be converted to Properties: unknown value '{value_char}' at position {index}.")
|
||||||
feature_name = feature.names.get(language)
|
feature_name = feature.names.get(language)
|
||||||
feature_value = value.names.get(language)
|
feature_value = value.names.get(language)
|
||||||
if (warn_level_flag and lemma is None and (category_name, index) in [(le[0], le[1]) for le in LEVEL_EXCEPTIONS]):
|
if (warn_level_flag and lemma is None and (category_name, index) in [(le[0], le[1]) for le in LEVEL_EXCEPTIONS]):
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ with open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
|
|||||||
long_description = f.read()
|
long_description = f.read()
|
||||||
|
|
||||||
setup(name='cjvt_conversion_utils',
|
setup(name='cjvt_conversion_utils',
|
||||||
version='0.4.1',
|
version='0.4.2',
|
||||||
description='CJVT conversion utilities',
|
description='CJVT conversion utilities',
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
|
|||||||
Reference in New Issue
Block a user