winIDEA SDK
test_save.py
1# This script is licensed under BSD License, see file LICENSE.txt.
2#
3# (c) TASKING Germany GmbH, 2023
4
5import os
6
7import isystem.connect as ic
8
9
10winidea_id = ''
11
12
13def test_save():
14 connMgr = ic.ConnectionMgr()
15 connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
16
17 docCtrl = ic.CDocumentController(connMgr, 'src/main.cpp', "r")
18
19 print("Saving selected document ('main.cpp')...")
20 docCtrl.save()
21
22 print("Saving selected document ('main.cpp') copy: 'main_copy.cpp'...")
23 try:
24 docCtrl.saveCopy('src/main_copy.cpp')
25 except Warning as wrn:
26 print("File existed and was overwritten!")
27
28 print("Saving selected document ('main.cpp') with a new name: 'main_saveAs.cpp'...")
29 try:
30 docCtrl.saveAs('src/main_saveAs.cpp')
31 except AttributeError as exc:
32 print("Could not save: " + str(exc))
33
34 # alternatively, save the document with GUI prompt:
35 # docCtrl.saveAsPrompt()
36
37
38if __name__ == "__main__":
39 test_save()