This module allows to analyze a USE OCL .use source file:

  • the file is load with use binary,
  • then a info model command is issue,
  • the canonical representation produced is finally parsed.

Either find some errors or create a model (see pyuseocl.model.Model)


UseOCLModelFile(useModelSourceFile) Abstraction of .use source file.


class pyuseocl.analyzer.UseOCLModelFile(useModelSourceFile)[source]

Abstraction of .use source file. This source file can be valid or not. In this later case a reference to the contained model will be available.

Analyze the given source file and returns a UseOCLModelFile. If valid, this object contains a model, otherwise it contains the list of errors as well as the USE OCL command exit code.

Parameters:useModelSourceFile (str) – The path of the ‘.use’ source file to analyze


see test.pyuseocl.test_analyzer

isValid = None

(bool) Indicates if the model file is valid, that is can be successfully parsed and compiled with use.

errors = None

(list[Error]) list of errors if any or empty list.

commandExitCode = None

(int) exit code of use command.

model = None

(Model) Model representing the file in a conceptual way or None if self.isValid is false


Save the model in the canonical form (returned by “info model”) in a given file.

Parameters:fileName (str|NoneType) – The output file name or None. If no file name is provided then the name of the source is taken but the extension will be ‘.can.use’ instead of ‘.use’
Returns:the name of the file generated.
Return type:str
printStatus(a, b, c)[source]

Print the status of the file:

  • the list of errors if the file is invalid,
  • a short summary of entities (classes, attributes, etc.) otherwise