Codeable Models API documentation

Codeable Models is a Python API for programmatically creating del akin to UML or EMF del. The goal of the module is to provide a lightweight codeable modeling API. The module is used as a foundation for working programmatically with del.

Typical use case for Codeable Models are:

  • Create del textually and be able to use textual tools such as search & replace, copy & paste, grep, and so on to edit them.

  • Ease model creation and manipulation through code - provided in Python scripts with little to no boilerplate code.

  • Using Python code to ensure model consistency, perform constraint checking, perform analyses, and calculate metrics.

  • Create domain del in your code and use them at runtime in your Python project, e.g. to realize a portion of the software system to reflect the domain model in a very literal way as envisaged in Domain-driven Design (DDD).

  • Generate visual representations of those del such as UML diagrams and tables, e.g. used to support understanding the big picture and communicating the model.

  • Generate other textual representations, such as Markdown or Latex texts.

  • Generate code and/or configuration scripts from the del.

Import it with:

import codeable_models

or import its classes and functions, e.g.:

from codeable_models import CClass, CMetaclass, CBundle, CException, CStereotype, add_links

Classes

The Codeable Models API offers of a number of classes and functions, each documented in a single section below. The main class hierarchy of Codeable Models is shown in the figures below.

_images/codeable_models_model_hierarchy.png

CAssociation(source, target[, descriptor])

CAssociation is used for representing associations.

CAttribute(**kwargs)

CAttribute is internally used for storing attributes, and can be used by the user for detailed setting or introspection of attribute data.

CBundlable(name, **kwargs)

CBundlable is a superclass for all elements in Codeable Models that can be placed in a CBundle, which is used for grouping elements.

CBundle([name])

CBundle is used to manage bundles, i.e., groups of modelling elements in Codeable Models.

CClass(metaclass[, name])

CClass is used to define classes.

CClassifier([name])

CClassifier is superclass of classifiers such as CClass and CMetaclass defining common features for classifiers.

CEnum([name])

CEnum is used for defining enumerations.

CException(value)

CException is a Python Exception that signals that an Exception is raised in Codeable Models.

CLayer([name])

Simple class to designate bundles as layers, and manage sub-/super-layer relations.

CLink(association, source_object, …)

CLink is used to define object links.

CMetaclass([name])

CMetaclass is used to define meta-classes.

CNamedElement(name, **kwargs)

CNamedElement is the superclass for all named elements in Codeable Models, such as CClass, CObject, and so on.

CObject(cl[, name])

CObject is used to define objects.

CPackage([name])

Simple class to designate bundles as packages.

CStereotype([name])

CStereotype is used to define stereotypes and stereotype instances.

Functions

add_links(link_definitions, **kwargs)

Function used to add multiple links at once, maybe to different source objects.

set_links(link_definitions[, do_add_links])

Sets multiple links by first deleting all existing links on the objects to be used in the links and then adding the links in the link_definitions with the same functionality as the add_links() function.

delete_links(link_definitions, **kwargs)

Function used to delete multiple links, maybe to different source objects.