Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
f" ontology."
)
if not this_manager.is_imported(parent_entry):
raise ParentEntryNotDeclaredException(
f"The parent entry {parent_entry} is not declared. It is "
f"neither in the base entries nor in custom entries. "
f"Please check them ontology specification, and make sure the "
f"entry is defined before this."
)
base_entry: Optional[str] = self.find_base_entry(
entry_name.class_name, parent_entry)
if base_entry is None:
raise OntologySpecError(
f"Cannot find the base entry for entry "
f"{entry_name.class_name} and {parent_entry}"
)
if base_entry not in self.top_init_args:
raise ParentEntryNotSupportedException(
f"Cannot add {entry_name.class_name} to the ontology as "
f"it's parent entry {parent_entry} is not supported. This is "
f"likely that the entries are not inheriting the allowed types."
)
# Take the property definitions of this entry.
properties: List[Dict] = schema.get(SchemaKeywords.attributes, [])
this_manager = self.import_managers.get(entry_name.module_name)
Returns:
Directory path in which the modules are created: either one of
the temporary directory or `destination_dir`.
"""
# Update the list of directories to be examined for imported configs
self.import_dirs.append(os.path.dirname(os.path.realpath(spec_path)))
merged_schemas: List[Dict] = []
# Generate ontology classes for the input json config and the configs
# it is dependent upon.
try:
self.parse_ontology_spec(spec_path, destination_dir,
merged_schema=merged_schemas)
except OntologySpecError:
logging.error("Error at parsing [%s]", spec_path)
raise
# Now generate all data.
# A temporary directory to save the generated file structure until the
# generation is completed and verified.
tempdir = tempfile.mkdtemp()
# Starting from here, we won't add any more modules to import.
self.import_managers.fix_all_modules()
logging.info('Working on %s', spec_path)
for writer in self.module_writers.writers():
logging.info('Writing module: %s', writer.module_name)
writer.write(tempdir, destination_dir, include_init)
pass
class OntologySourceNotFoundException(OntologySpecError):
pass
class OntologyAlreadyGeneratedException(OntologySpecError):
pass
class ParentEntryNotDeclaredException(OntologySpecError):
pass
class ParentEntryNotSupportedException(OntologySpecError):
pass
class TypeNotDeclaredException(OntologySpecError):
pass
class NoDefaultClassAttributeException(OntologySpecError):
pass
class UnsupportedTypeException(OntologySpecError):
pass
class InvalidIdentifierException(ValueError):
pass
class DuplicatedAttributesWarning(OntologyGenerationWarning):
pass
class OntologySpecError(ValueError):
pass
class OntologySpecValidationError(OntologySpecError):
pass
class OntologySourceNotFoundException(OntologySpecError):
pass
class OntologyAlreadyGeneratedException(OntologySpecError):
pass
class ParentEntryNotDeclaredException(OntologySpecError):
pass
class ParentEntryNotSupportedException(OntologySpecError):
pass
class TypeNotDeclaredException(OntologySpecError):
pass
class DuplicateEntriesWarning(OntologyGenerationWarning):
pass
class DuplicatedAttributesWarning(OntologyGenerationWarning):
pass
class OntologySpecError(ValueError):
pass
class OntologySpecValidationError(OntologySpecError):
pass
class OntologySourceNotFoundException(OntologySpecError):
pass
class OntologyAlreadyGeneratedException(OntologySpecError):
pass
class ParentEntryNotDeclaredException(OntologySpecError):
pass
class ParentEntryNotSupportedException(OntologySpecError):
pass
class ParentEntryNotDeclaredException(OntologySpecError):
pass
class ParentEntryNotSupportedException(OntologySpecError):
pass
class TypeNotDeclaredException(OntologySpecError):
pass
class NoDefaultClassAttributeException(OntologySpecError):
pass
class UnsupportedTypeException(OntologySpecError):
pass
class InvalidIdentifierException(ValueError):
pass
class CodeGenerationException(BaseException):
pass
pass
class ParentEntryNotSupportedException(OntologySpecError):
pass
class TypeNotDeclaredException(OntologySpecError):
pass
class NoDefaultClassAttributeException(OntologySpecError):
pass
class UnsupportedTypeException(OntologySpecError):
pass
class InvalidIdentifierException(ValueError):
pass
class CodeGenerationException(BaseException):
pass