Bases: gt.core.VisitorProcess
Export process is a base class for the serialization processes. It is a child of gt.core.VisitorProcess with support of writing serialization data to a file while visiting gt.core.Graph elements. For a better readability, each graph element gets a unique name depending on its class. Uses gt.core.VisitorProcess.visit_event event as a trigger for the export functions.
Target file name parameter, a part of the start context.
Element id pattern.
Starts the export, opens the file if specified.
Parameters: | new (bool.) – if True, the file content will be cleared. |
---|
Writes data to an open file or to the stdout.
Parameters: | data (str.) – data to be written. |
---|
Stops the writing to a file and closes it, if it was opened.
Parameters: | finished (bool.) – True if the process is finished. |
---|
Converts the element type to the id, for example gt.core.ComplexNotion will be converted to “cn”, gt.core.Relation will be converted to “r” and so on.
Parameters: | element – object to get the type id. |
---|---|
Return type: | str. |
Returns: | class name converted to the id. |
Gets the serialization id for the specified type: “type_id_NN”, where NN is a 0-based counter for the type. Increases the counter after use. Uses ExportProcess.ID_PATTERN as a template.
Parameters: | type_id (str.) – type identifier |
---|---|
Return type: | str. |
Returns: | serialization id for the type. |
Gets the non-graph element identifier.
Parameters: | obj – input object. |
---|---|
Returns: | object id. |
Return type: | str. |
Gets the unique element serialization id. Safe to call multiple times, will return the same id for the same element.
Parameters: | element – serializing object. |
---|---|
Return type: | str. |
Returns: | element id string. |
Called when a graph is visited for serialization.
Parameters: | graph – serializing graph. |
---|---|
Return type: | str. |
Returns: | export string to write to the file or None. |
Called when a notion is visited for serialization.
Parameters: | notion – serializing notion. |
---|---|
Return type: | str. |
Returns: | export string to write to the file or None. |
Called when a relation is visited for serialization.
Parameters: | relation – serializing graph. |
---|---|
Return type: | str. |
Returns: | export string to write to the file or None. |
Export event, calls ExportProcess.export_graph(), ExportProcess.export_notion(), or ExportProcess.export_relation() depending on gt.core.Process.current element type. If export data is not empty, it will be written to the file using ExportProcess.write_data().
Returns: | True |
---|---|
Return type: | bool. |
Gets the file name from ExportProcess.FILENAME context parameter, opens it using ExportProcess.start_export() with new=True and clears internal counters.
Opens current ExportProcess.filename to continue the writing using ExportProcess.start_export() with new=False.
In addition to gt.core.Process.handle() closes the file, calling ExportProcess.stop_export().
In addition to gt.core.Process.setup_events() adds ExportProcess.on_export() as a visit event.
Target file name (read-only).
Returns: | current file name. |
---|---|
Return type: | str. |
Output buffer (read-only).
Returns: | export buffer, if no output file specified. |
---|---|
Return type: | str. |
Bases: gt.export.ExportProcess
Exports the graph to the DOT language (http://en.wikipedia.org/wiki/DOT_(graph_description_language)) format.
Turns the gt.core.Relation‘s condition to a printable string.
Parameters: | relation (Relation.) – input relation. |
---|---|
Returns: | condition string or an empty string. |
Return type: | str. |
Creates the DOT string for the node, like a -> b [label = “*”]
Parameters: |
|
---|---|
Returns: | DOT string ready for export. |
Return type: | str. |
Gets the non-element object id. Uses a separate list to export the objects after the elements export.
Parameters: | obj – non-element object. |
---|---|
Returns: | object id. |
Return type: | str. |
Gets the unique element serialization id. Supports empty elements (for relations without gt.core.Relation.object).
Parameters: | element – serializing object. |
---|---|
Returns: | object id. |
Return type: | str. |
Exports an empty element as a point shape.
Parameters: | counter (int.) – element counter |
---|---|
Returns: | export string to write to the file or None. |
Return type: | str. |
Exports a non-element object as a rect shape.
Parameters: | name – object’s name. |
---|---|
Returns: | export string to write to the file or None. |
Return type: | str. |
When finished dumps empty and non-graph objects and puts the closing bracket.
Parameters: | finished (bool.) – True if the process is finished. |
---|