Project management#

This section contains the classes related to Scade One projects.

from ansys.scadeone.core import ScadeOne, ProjectFile

with ScadeOne() as app:
  project = app.load_project("project.sproj")
  ...

Project documentation#

This section gives the description of project class which is used to manage Scade One projects.

Projects are used by ScadeOne objects, and projects have a link to the application. To deal with the cross-links, we use the IProject interface [1].

class ansys.scadeone.core.project.IProject#

Bases: object

Interface class

class ansys.scadeone.core.project.Project(app: IScadeOne, project: ProjectStorage)#

Bases: IProject

This class is the entry point of a project.

dependencies(all=False) List[Self]#

Project dependencies as list of Projects.

If all is True, include recursively dependencies of dependencies.

A dependency occurs only once.

swan_sources(all=False) List[SwanFile]#

Return all Swan sources from project.

If all is True, include also sources from project dependencies.

Returns:
list[SwanFile]

List of all SwanFile objects.

property app: IScadeOne#

Access to current Scade One application.

property data#

Project JSON data.

property directory: Path | None#

Project directory: Path if storage is a file, else None.

property model#

Access to model represented by the sources.

property storage: ProjectStorage#

Project storage.

Project items#

A project can manipulate different items saved using the storage module. The API handles projects and Swan sources (.swan and .swani files).

Project file#

class ansys.scadeone.core.common.storage.ProjectFile(file: str | Path)#

Bases: FileStorage, ProjectStorage

Project as a file.

content() str#

Content of file.

dump(**kw)#

Uses self.json to update storage content and returns self.

See json.dumps() for detailed interface.

exists() bool#

True when file exists.

load(**kw)#

Loads content of JSON data into json property and returns self.

See json.loads() for detailed interface.

set_content(data: str) str#

Sets content and write it to underlying file.

property json#

JSON content. Any modification is propagated to the underlying JSON object.

property path: Path#

Saved path.

property source: str#

Source origin: file name, string, etc.

Swan code#

class ansys.scadeone.core.common.storage.SwanFile(file: str | Path)#

Bases: FileStorage, SwanStorage

Swan code within a file.

Parameters:
filePath

File containing the Swan source.

check_swan_version()#

Check Swan version information.

Raises:
ScadeOneException

When version information is missing or invalid.

check_swant_version()#

Check Swan test harness version information.

Raises:
ScadeOneException

When version information is missing or invalid.

content() str#

Content of file.

exists() bool#

True when file exists.

static extract_version(source: str) dict | None#

Extracts version information from a Swan source.

Parameters:
sourcestr

Version information as a string.

Returns:
Union[dict, None]

Either the version information as a dictionary, or None if no version found.

static gen_version(is_harness=False)#

Generate the version for a Swan file.

Parameters:
is_harnessbool

True if the harness version is needed

Returns:
str

Version

set_content(data: str) str#

Sets content and write it to underlying file.

property is_interface#

True when file is an interface code.

property is_module#

True when file is a module code.

property is_test#

True when file is an test code.

property name: str#

Returns basename of source file (no suffix).

property path: Path#

Saved path.

property source: str#

Source origin: file name, string, etc.

property version: dict | None#

Swan version information.

Footnotes