Sun, 14 Apr 2019 15:09:21 +0200
Major restructuring of the source tree to get prepared for a setup.py based installation.
6547
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

1  # * coding: utf8 * 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

2  
6645
ad476851d7e0
Updated copyright for 2019.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
6547
diff
changeset

3  # Copyright (c) 2011  2019 Detlev Offenbach <detlev@dieoffenbachs.de> 
6547
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

4  # 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

5  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

6  """ 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

7  Module to get sys.path of an external interpreter. 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

8  """ 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

9  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

10  from __future__ import print_function 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

11  try: 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

12  bytes = unicode # __IGNORE_EXCEPTION__ 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

13  except NameError: 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

14  pass 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

15  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

16  import sys 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

17  import json 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

18  import xml.etree.ElementTree 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

19  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

20  try: 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

21  from PyQt5.QtCore import qVersion, QMetaMethod, QByteArray 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

22  from PyQt5.QtWidgets import QAction, QWidget, QApplication 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

23  from PyQt5 import uic 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

24  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

25  pyqtType = 5 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

26  except ImportError: 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

27  try: 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

28  # try a potential PyQt4 installation 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

29  from PyQt4.QtCore import qVersion, QMetaMethod, QByteArray 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

30  from PyQt4.QtGui import QAction, QWidget, QApplication 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

31  from PyQt4 import uic 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

32  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

33  pyqtType = 4 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

34  except ImportError: 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

35  print("Neither PyQt5 nor PyQt4 found.") 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

36  sys.exit(1) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

37  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

38  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

39  def objectName(formFile, projectPath): 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

40  """ 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

41  Function to get the object name of a form. 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

42  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

43  @param formFile file name of the form 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

44  @type str 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

45  @param projectPath directory name of the project 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

46  @type str 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

47  """ 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

48  app = QApplication([]) # __IGNORE_WARNING__ 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

49  try: 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

50  dlg = uic.loadUi(formFile, package=projectPath) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

51  print(dlg.objectName()) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

52  sys.exit(0) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

53  except (AttributeError, ImportError, 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

54  xml.etree.ElementTree.ParseError) as err: 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

55  print(str(err)) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

56  sys.exit(1) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

57  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

58  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

59  def className(formFile, projectPath): 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

60  """ 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

61  Function to get the class name of a form. 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

62  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

63  @param formFile file name of the form 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

64  @type str 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

65  @param projectPath directory name of the project 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

66  @type str 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

67  """ 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

68  app = QApplication([]) # __IGNORE_WARNING__ 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

69  try: 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

70  dlg = uic.loadUi(formFile, package=projectPath) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

71  print(dlg.metaObject().className()) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

72  sys.exit(0) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

73  except (AttributeError, ImportError, 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

74  xml.etree.ElementTree.ParseError) as err: 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

75  print(str(err)) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

76  sys.exit(1) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

77  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

78  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

79  def __mapType(type_): 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

80  """ 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

81  Private function to map a type as reported by Qt's meta object to the 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

82  correct Python type. 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

83  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

84  @param type_ type as reported by Qt 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

85  @type QByteArray or bytes 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

86  @return mapped Python type 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

87  @rtype str 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

88  """ 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

89  mapped = bytes(type_).decode() 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

90  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

91  # I. always check for * 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

92  mapped = mapped.replace("*", "") 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

93  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

94  if pyqtType != 4: 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

95  # 1. check for const 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

96  mapped = mapped.replace("const ", "") 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

97  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

98  # 2. replace QString and QStringList 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

99  mapped = mapped.replace("QStringList", "list")\ 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

100  .replace("QString", "str") 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

101  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

102  # 3. replace double by float 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

103  mapped = mapped.replace("double", "float") 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

104  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

105  return mapped 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

106  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

107  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

108  def signatures(formFile, projectPath): 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

109  """ 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

110  Function to get the signatures of form elements. 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

111  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

112  @param formFile file name of the form 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

113  @type str 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

114  @param projectPath directory name of the project 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

115  @type str 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

116  """ 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

117  objectsList = [] 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

118  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

119  app = QApplication([]) # __IGNORE_WARNING__ 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

120  try: 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

121  dlg = uic.loadUi(formFile, package=projectPath) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

122  objects = dlg.findChildren(QWidget) + dlg.findChildren(QAction) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

123  for obj in objects: 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

124  name = obj.objectName() 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

125  if not name or name.startswith("qt_"): 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

126  # ignore unnamed or internal objects 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

127  continue 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

128  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

129  metaObject = obj.metaObject() 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

130  objectDict = { 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

131  "name": name, 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

132  "class_name": metaObject.className(), 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

133  "methods": [], 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

134  } 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

135  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

136  for index in range(metaObject.methodCount()): 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

137  metaMethod = metaObject.method(index) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

138  if metaMethod.methodType() == QMetaMethod.Signal: 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

139  signatureDict = { 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

140  "methods": [] 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

141  } 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

142  if qVersion().startswith("5."): 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

143  signatureDict["signature"] = "on_{0}_{1}".format( 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

144  name, 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

145  bytes(metaMethod.methodSignature()).decode() 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

146  ) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

147  else: 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

148  signatureDict["signature"] = "on_{0}_{1}".format( 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

149  name, 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

150  metaMethod.signature() 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

151  ) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

152  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

153  if qVersion().startswith("5."): 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

154  signatureDict["methods"].append("on_{0}_{1}".format( 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

155  name, 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

156  bytes(metaMethod.methodSignature()) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

157  .decode().split("(")[0] 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

158  )) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

159  else: 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

160  signatureDict["methods"].append("on_{0}_{1}".format( 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

161  name, 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

162  metaMethod.signature().split("(")[0] 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

163  )) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

164  signatureDict["methods"].append("{0}({1})".format( 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

165  signatureDict["methods"][1], 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

166  ", ".join([ 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

167  __mapType(t) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

168  for t in metaMethod.parameterTypes() 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

169  ]) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

170  )) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

171  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

172  returnType = __mapType( 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

173  metaMethod.typeName().encode()) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

174  if returnType == 'void': 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

175  returnType = "" 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

176  signatureDict["return_type"] = returnType 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

177  parameterTypesList = [ 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

178  __mapType(t) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

179  for t in metaMethod.parameterTypes() 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

180  ] 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

181  signatureDict["parameter_types"] = parameterTypesList 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

182  pyqtSignature = ", ".join(parameterTypesList) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

183  signatureDict["pyqt_signature"] = pyqtSignature 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

184  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

185  parameterNames = metaMethod.parameterNames() 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

186  if parameterNames: 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

187  for index in range(len(parameterNames)): 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

188  if not parameterNames[index]: 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

189  parameterNames[index] = \ 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

190  QByteArray("p{0:d}".format(index) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

191  .encode("utf8")) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

192  parameterNamesList = [bytes(n).decode() 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

193  for n in parameterNames] 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

194  signatureDict["parameter_names"] = parameterNamesList 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

195  methNamesSig = ", ".join(parameterNamesList) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

196  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

197  if methNamesSig: 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

198  if qVersion().startswith("5."): 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

199  pythonSignature = \ 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

200  "on_{0}_{1}(self, {2})".format( 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

201  name, 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

202  bytes(metaMethod.methodSignature()) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

203  .decode().split("(")[0], 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

204  methNamesSig) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

205  else: 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

206  pythonSignature = \ 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

207  "on_{0}_{1}(self, {2})".format( 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

208  name, 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

209  metaMethod.signature().split("(")[0], 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

210  methNamesSig) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

211  else: 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

212  if qVersion().startswith("5."): 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

213  pythonSignature = "on_{0}_{1}(self)".format( 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

214  name, 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

215  bytes(metaMethod.methodSignature()) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

216  .decode().split("(")[0]) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

217  else: 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

218  pythonSignature = "on_{0}_{1}(self)".format( 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

219  name, 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

220  metaMethod.signature().split("(")[0]) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

221  signatureDict["python_signature"] = pythonSignature 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

222  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

223  objectDict["methods"].append(signatureDict) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

224  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

225  objectsList.append(objectDict) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

226  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

227  print(json.dumps(objectsList)) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

228  sys.exit(0) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

229  except (AttributeError, ImportError, 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

230  xml.etree.ElementTree.ParseError) as err: 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

231  print(str(err)) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

232  sys.exit(1) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

233  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

234  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

235  if __name__ == "__main__": 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

236  if len(sys.argv) != 4: 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

237  print("Wrong number of arguments.") 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

238  sys.exit(1) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

239  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

240  if sys.argv[1] == "object_name": 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

241  objectName(sys.argv[2], sys.argv[3]) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

242  elif sys.argv[1] == "class_name": 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

243  className(sys.argv[2], sys.argv[3]) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

244  elif sys.argv[1] == "signatures": 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

245  signatures(sys.argv[2], sys.argv[3]) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

246  else: 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

247  print("Unknow operation given.") 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

248  sys.exit(1) 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

249  
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

250  # 
77c817301ca1
CreateDialogCodeDialog: third attempt on getting this working with projects using a virtual environment different from the one used to run eric.
Detlev Offenbach <detlev@dieoffenbachs.de>
parents:
diff
changeset

251  # eflag: noqa = M701, M801 