omnetpp.scave.analysis¶
This module allows reading, writing, creating and editing
OMNeT++ Analysis (.anf) files, querying their contents, and
running the charts scripts they contain. The main user of this
module is opp_charttool.
Attributes¶
Classes¶
Represents a dialog page in a |
|
Represents a chart in an |
|
Represents a folder in an |
|
This is an abstraction of an IDE workspace, and makes it possible to map |
|
Represents an OMNeT++ Analysis, i.e. the contents of an |
Functions¶
|
Reads the given anf file and returns its content as an |
Module Contents¶
-
class DialogPage(id: str =
None, label: str ='', content: str ='')[source]¶ Represents a dialog page in a
Chart. Dialog pages have an ID, a label (which the IDE displays on the page’s tab in the Chart Properties dialog), and XSWT content (which describes the UI controls on the page).
-
class Chart(id: str =
None, name: str ='', type: str ='MATPLOTLIB', template: str =None, icon: str =None, script: str ='', dialog_pages=list(), properties=dict(), created_with: str =None)[source]¶ Represents a chart in an
Analysis. Charts have an ID, a name, a chart script (a Python script that mainly uses Pandas and theomnetpp.scave.*modules), dialog pages (which make up the contents of the Chart Properties dialog in the IDE), and properties (which are what the Chart Properties dialog in the IDE edits).
-
class Folder(id: str =
None, name: str ='', items=list())[source]¶ Represents a folder in an
Analysis. Folders may contain charts and further folders.
-
class Workspace(workspace_dir=
None, project_locations=None)[source]¶ This is an abstraction of an IDE workspace, and makes it possible to map workspace paths to filesystem paths. This is necessary because the inputs in the
Analysisare workspace paths. The class tolerates if workspace metadata (the.metadatasubdirectory) is missing; then it looks for projects in directories adjacent to other known projects.-
static find_workspace(dir=
None)[source]¶ Utility function: Find the IDE workspace directory searching from the given directory (or the current dir if not given) upwards. The workspace directory of the Eclipse-based IDE can be recognized by having a
.metadatasubdir. If the workspace is not found, None is returned.
-
static find_enclosing_project_location(file=
None)[source]¶ Utility function: Find the project directory searching from the given directory (or the current dir if not given) upwards. Project directories of the Eclipse-based IDE can be recognized by having a
.projectfile in them.
- get_project_name(project_dir)[source]¶
Returns the “real” name of the project from the
.project(project description) file in the given project directory.
-
find_enclosing_project(file=
None)[source]¶ Find the project name searching from the given directory (or the current dir if not given) upwards. Project directories of the Eclipse-based IDE can be recognized by having a
.projectfile in them.
- get_project_location(project_name)[source]¶
Returns the location of the given workspace project in the filesystem path.
- get_referenced_projects(project_name)[source]¶
Returns a list of projects that are referenced by the given project.
-
get_all_referenced_projects(project_name, include_self=
False)[source]¶ Returns a list of projects that are referenced by the given project, even transitively.
-
static find_workspace(dir=
-
class Analysis(inputs=
list(), items=list())[source]¶ Represents an OMNeT++ Analysis, i.e. the contents of an
anffile. Methods allow reading/writinganffiles, and running the charts in them for interactive display, image/data export or other side effects.- static from_anf_file(anf_file_name)[source]¶
Reads the given anf file and returns its content as an
Analysisobject.
-
collect_charts(folder=
None)[source]¶ Collects and returns a list of all charts in the specified folder, or in this Analysis if no folder is given.
- get_item_path(item)[source]¶
Returns the path of the item (Chart or Folder) within the Analysis as list of path segments (Folder items). The returned list includes both the root folder of the Analysis and the item itself. If the item is not part of the Analysis, None is returned.
-
get_item_path_as_string(item, separator=
' / ')[source]¶ Returns the path of the item (Chart or Folder) within the Analysis as a string. Segments are joined with the given separator. The returned string includes the item name itself, but not the root folder (i.e. for items in the root folder, the path string equals to the item name). If the item is not part of the Analysis, None is returned.
-
run_chart(chart, wd, workspace, extra_props=
dict(), show=False, suppress_print=False)[source]¶ Runs a chart script with the given working directory, workspace, and extra properties in addition to the chart’s properties. If
show=True, it callsplt.show()if it was not already called by the script.
-
export_image(chart, wd, workspace, format=
'svg', target_folder=None, filename=None, width=None, height=None, dpi=300, enforce=True, extra_props=dict(), suppress_print=False)[source]¶ Runs a chart script for image export. This method just calls
run_chart()with extra properties that instruct the chart script to perform image export. (It is assumed that the chart script invokesutils.export_image_if_needed()or implements equivalent functionality).
-
export_data(chart, wd, workspace, format=
'csv', target_folder=None, filename=None, enforce=True, extra_props=dict(), suppress_print=False)[source]¶ Runs a chart script for data export. This method just calls
run_chart()with extra properties that instruct the chart script to perform data export. (It is assumed that the chart script invokesutils.export_data_if_needed()or implements equivalent functionality).
- load_anf_file(anf_file_name)[source]¶
Reads the given anf file and returns its content as an
Analysisobject. This is synonym forAnalysis.from_anf_file().