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.

class ansys.scadeone.core.project.IProject#

Bases: object

Interface class

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

Bases: IProject, ProjectCreator

This class is the entry point of a project.

build_sproj() None#

Init SPROJ starting content.

check_exists(parent_path: Path | str) bool#

Return true if any of the project modules or sproj already exists attention, dependencies may not be checked.

dependencies(all=False) List[Project]#

Project dependencies as list of Projects.

If all is True, include recursively dependencies of dependencies.

A dependency occurs only once.

get_job(name: str) Job | None#

Get a job from its name.

load_jobs() List[Job]#

(Re)load and return all the jobs of a project.

save() None#

Save the project, that is all its modules.

Two cases:

  • new project, saving to the .sproj location

  • loaded project, saving and replacing old files

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: _ProjectData#

Project JSON data.

property directory: Path | None#

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

property jobs: List[Job]#

Return job files of the project.

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.

set_content(data: str) str#

Sets content and write it to underlying file.

property is_interface: bool#

True when file is an interface code.

property is_module: bool#

True when file is a module code.

property is_test: bool#

True when file is a 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