308 project type (list of string) |
308 project type (list of string) |
309 """ |
309 """ |
310 if progLanguages: |
310 if progLanguages: |
311 for progLanguage in progLanguages: |
311 for progLanguage in progLanguages: |
312 if progLanguage not in self.__projectProgLanguages: |
312 if progLanguage not in self.__projectProgLanguages: |
313 E5MessageBox.critical(self.ui, |
313 E5MessageBox.critical( |
|
314 self.ui, |
314 self.trUtf8("Registering Project Type"), |
315 self.trUtf8("Registering Project Type"), |
315 self.trUtf8( |
316 self.trUtf8( |
316 """<p>The Programming Language <b>{0}</b> is not""" |
317 """<p>The Programming Language <b>{0}</b> is not""" |
317 """ supported.</p>""")\ |
318 """ supported.</p>""")\ |
318 .format(progLanguage) |
319 .format(progLanguage) |
319 ) |
320 ) |
320 return |
321 return |
321 |
322 |
322 if type_ in self.__projectProgLanguages[progLanguage]: |
323 if type_ in self.__projectProgLanguages[progLanguage]: |
323 E5MessageBox.critical(self.ui, |
324 E5MessageBox.critical( |
|
325 self.ui, |
324 self.trUtf8("Registering Project Type"), |
326 self.trUtf8("Registering Project Type"), |
325 self.trUtf8( |
327 self.trUtf8( |
326 """<p>The Project type <b>{0}</b> is already""" |
328 """<p>The Project type <b>{0}</b> is already""" |
327 """ registered with Programming Language""" |
329 """ registered with Programming Language""" |
328 """ <b>{1}</b>.</p>""")\ |
330 """ <b>{1}</b>.</p>""")\ |
329 .format(type_, progLanguage) |
331 .format(type_, progLanguage) |
330 ) |
332 ) |
331 return |
333 return |
332 |
334 |
333 if type_ in self.__projectTypes: |
335 if type_ in self.__projectTypes: |
334 E5MessageBox.critical(self.ui, |
336 E5MessageBox.critical( |
|
337 self.ui, |
335 self.trUtf8("Registering Project Type"), |
338 self.trUtf8("Registering Project Type"), |
336 self.trUtf8("""<p>The Project type <b>{0}</b> is already""" |
339 self.trUtf8("""<p>The Project type <b>{0}</b> is already""" |
337 """ registered.</p>""").format(type_) |
340 """ registered.</p>""").format(type_) |
338 ) |
341 ) |
339 else: |
342 else: |
662 reader.readXML() |
665 reader.readXML() |
663 res = not reader.hasError() |
666 res = not reader.hasError() |
664 f.close() |
667 f.close() |
665 else: |
668 else: |
666 QApplication.restoreOverrideCursor() |
669 QApplication.restoreOverrideCursor() |
667 E5MessageBox.critical(self.ui, |
670 E5MessageBox.critical( |
|
671 self.ui, |
668 self.trUtf8("Read project file"), |
672 self.trUtf8("Read project file"), |
669 self.trUtf8( |
673 self.trUtf8( |
670 "<p>The project file <b>{0}</b> could not be read.</p>")\ |
674 "<p>The project file <b>{0}</b> could not be read.</p>")\ |
671 .format(fn)) |
675 .format(fn)) |
672 return False |
676 return False |
761 from E5XML.ProjectWriter import ProjectWriter |
765 from E5XML.ProjectWriter import ProjectWriter |
762 ProjectWriter(f, os.path.splitext( |
766 ProjectWriter(f, os.path.splitext( |
763 os.path.basename(fn))[0]).writeXML() |
767 os.path.basename(fn))[0]).writeXML() |
764 res = True |
768 res = True |
765 else: |
769 else: |
766 E5MessageBox.critical(self.ui, |
770 E5MessageBox.critical( |
|
771 self.ui, |
767 self.trUtf8("Save project file"), |
772 self.trUtf8("Save project file"), |
768 self.trUtf8( |
773 self.trUtf8( |
769 "<p>The project file <b>{0}</b> could not be" |
774 "<p>The project file <b>{0}</b> could not be" |
770 " written.</p>").format(fn)) |
775 " written.</p>").format(fn)) |
771 res = False |
776 res = False |
796 from E5XML.UserProjectReader import UserProjectReader |
801 from E5XML.UserProjectReader import UserProjectReader |
797 reader = UserProjectReader(f, self) |
802 reader = UserProjectReader(f, self) |
798 reader.readXML() |
803 reader.readXML() |
799 f.close() |
804 f.close() |
800 else: |
805 else: |
801 E5MessageBox.critical(self.ui, |
806 E5MessageBox.critical( |
|
807 self.ui, |
802 self.trUtf8("Read user project properties"), |
808 self.trUtf8("Read user project properties"), |
803 self.trUtf8( |
809 self.trUtf8( |
804 "<p>The user specific project properties file" |
810 "<p>The user specific project properties file" |
805 " <b>{0}</b> could not be read.</p>").format(fn)) |
811 " <b>{0}</b> could not be read.</p>").format(fn)) |
806 |
812 |
819 from E5XML.UserProjectWriter import UserProjectWriter |
825 from E5XML.UserProjectWriter import UserProjectWriter |
820 UserProjectWriter( |
826 UserProjectWriter( |
821 f, os.path.splitext(os.path.basename(fn))[0]).writeXML() |
827 f, os.path.splitext(os.path.basename(fn))[0]).writeXML() |
822 f.close() |
828 f.close() |
823 else: |
829 else: |
824 E5MessageBox.critical(self.ui, |
830 E5MessageBox.critical( |
|
831 self.ui, |
825 self.trUtf8("Save user project properties"), |
832 self.trUtf8("Save user project properties"), |
826 self.trUtf8( |
833 self.trUtf8( |
827 "<p>The user specific project properties file <b>{0}</b>" |
834 "<p>The user specific project properties file <b>{0}</b>" |
828 " could not be written.</p>").format(fn)) |
835 " could not be written.</p>").format(fn)) |
829 |
836 |
852 If this flag is true, no errors are reported. |
859 If this flag is true, no errors are reported. |
853 @keyparam indicator indicator string (string) |
860 @keyparam indicator indicator string (string) |
854 """ |
861 """ |
855 if self.pfile is None: |
862 if self.pfile is None: |
856 if not quiet: |
863 if not quiet: |
857 E5MessageBox.critical(self.ui, |
864 E5MessageBox.critical( |
|
865 self.ui, |
858 self.trUtf8("Read project session"), |
866 self.trUtf8("Read project session"), |
859 self.trUtf8("Please save the project first.")) |
867 self.trUtf8("Please save the project first.")) |
860 return |
868 return |
861 |
869 |
862 fn, ext = os.path.splitext(os.path.basename(self.pfile)) |
870 fn, ext = os.path.splitext(os.path.basename(self.pfile)) |
869 reader = SessionReader(f, False) |
877 reader = SessionReader(f, False) |
870 reader.readXML(quiet=quiet) |
878 reader.readXML(quiet=quiet) |
871 f.close() |
879 f.close() |
872 else: |
880 else: |
873 if not quiet: |
881 if not quiet: |
874 E5MessageBox.critical(self.ui, |
882 E5MessageBox.critical( |
|
883 self.ui, |
875 self.trUtf8("Read project session"), |
884 self.trUtf8("Read project session"), |
876 self.trUtf8( |
885 self.trUtf8( |
877 "<p>The project session file <b>{0}</b> could not be" |
886 "<p>The project session file <b>{0}</b> could not be" |
878 " read.</p>").format(fn)) |
887 " read.</p>").format(fn)) |
879 |
888 |
885 If this flag is true, no errors are reported. |
894 If this flag is true, no errors are reported. |
886 @keyparam indicator indicator string (string) |
895 @keyparam indicator indicator string (string) |
887 """ |
896 """ |
888 if self.pfile is None: |
897 if self.pfile is None: |
889 if not quiet: |
898 if not quiet: |
890 E5MessageBox.critical(self.ui, |
899 E5MessageBox.critical( |
|
900 self.ui, |
891 self.trUtf8("Save project session"), |
901 self.trUtf8("Save project session"), |
892 self.trUtf8("Please save the project first.")) |
902 self.trUtf8("Please save the project first.")) |
893 return |
903 return |
894 |
904 |
895 fn, ext = os.path.splitext(os.path.basename(self.pfile)) |
905 fn, ext = os.path.splitext(os.path.basename(self.pfile)) |
902 SessionWriter( |
912 SessionWriter( |
903 f, os.path.splitext(os.path.basename(fn))[0]).writeXML() |
913 f, os.path.splitext(os.path.basename(fn))[0]).writeXML() |
904 f.close() |
914 f.close() |
905 else: |
915 else: |
906 if not quiet: |
916 if not quiet: |
907 E5MessageBox.critical(self.ui, |
917 E5MessageBox.critical( |
|
918 self.ui, |
908 self.trUtf8("Save project session"), |
919 self.trUtf8("Save project session"), |
909 self.trUtf8( |
920 self.trUtf8( |
910 "<p>The project session file <b>{0}</b> could not be" |
921 "<p>The project session file <b>{0}</b> could not be" |
911 " written.</p>").format(fn)) |
922 " written.</p>").format(fn)) |
912 |
923 |
913 def __deleteSession(self): |
924 def __deleteSession(self): |
914 """ |
925 """ |
915 Private method to delete the session file. |
926 Private method to delete the session file. |
916 """ |
927 """ |
917 if self.pfile is None: |
928 if self.pfile is None: |
918 E5MessageBox.critical(self.ui, |
929 E5MessageBox.critical( |
|
930 self.ui, |
919 self.trUtf8("Delete project session"), |
931 self.trUtf8("Delete project session"), |
920 self.trUtf8("Please save the project first.")) |
932 self.trUtf8("Please save the project first.")) |
921 return |
933 return |
922 |
934 |
923 fname, ext = os.path.splitext(os.path.basename(self.pfile)) |
935 fname, ext = os.path.splitext(os.path.basename(self.pfile)) |
926 self.getProjectManagementDir(), "{0}.e4s".format(fname))]: |
938 self.getProjectManagementDir(), "{0}.e4s".format(fname))]: |
927 if os.path.exists(fn): |
939 if os.path.exists(fn): |
928 try: |
940 try: |
929 os.remove(fn) |
941 os.remove(fn) |
930 except OSError: |
942 except OSError: |
931 E5MessageBox.critical(self.ui, |
943 E5MessageBox.critical( |
|
944 self.ui, |
932 self.trUtf8("Delete project session"), |
945 self.trUtf8("Delete project session"), |
933 self.trUtf8( |
946 self.trUtf8( |
934 "<p>The project session file <b>{0}</b> could" |
947 "<p>The project session file <b>{0}</b> could" |
935 " not be deleted.</p>").format(fn)) |
948 " not be deleted.</p>").format(fn)) |
936 |
949 |
937 def __readTasks(self): |
950 def __readTasks(self): |
938 """ |
951 """ |
939 Private method to read in the project tasks file (.e4t). |
952 Private method to read in the project tasks file (.e4t). |
940 """ |
953 """ |
941 if self.pfile is None: |
954 if self.pfile is None: |
942 E5MessageBox.critical(self.ui, |
955 E5MessageBox.critical( |
|
956 self.ui, |
943 self.trUtf8("Read tasks"), |
957 self.trUtf8("Read tasks"), |
944 self.trUtf8("Please save the project first.")) |
958 self.trUtf8("Please save the project first.")) |
945 return |
959 return |
946 |
960 |
947 fn, ext = os.path.splitext(os.path.basename(self.pfile)) |
961 fn, ext = os.path.splitext(os.path.basename(self.pfile)) |
953 from E5XML.TasksReader import TasksReader |
967 from E5XML.TasksReader import TasksReader |
954 reader = TasksReader(f, True) |
968 reader = TasksReader(f, True) |
955 reader.readXML() |
969 reader.readXML() |
956 f.close() |
970 f.close() |
957 else: |
971 else: |
958 E5MessageBox.critical(self.ui, |
972 E5MessageBox.critical( |
|
973 self.ui, |
959 self.trUtf8("Read tasks"), |
974 self.trUtf8("Read tasks"), |
960 self.trUtf8( |
975 self.trUtf8( |
961 "<p>The tasks file <b>{0}</b> could not be read.</p>")\ |
976 "<p>The tasks file <b>{0}</b> could not be read.</p>")\ |
962 .format(fn)) |
977 .format(fn)) |
963 |
978 |
972 |
987 |
973 fn = os.path.join(self.getProjectManagementDir(), '{0}.e4t'.format(fn)) |
988 fn = os.path.join(self.getProjectManagementDir(), '{0}.e4t'.format(fn)) |
974 f = QFile(fn) |
989 f = QFile(fn) |
975 ok = f.open(QIODevice.WriteOnly) |
990 ok = f.open(QIODevice.WriteOnly) |
976 if not ok: |
991 if not ok: |
977 E5MessageBox.critical(self.ui, |
992 E5MessageBox.critical( |
|
993 self.ui, |
978 self.trUtf8("Save tasks"), |
994 self.trUtf8("Save tasks"), |
979 self.trUtf8( |
995 self.trUtf8( |
980 "<p>The tasks file <b>{0}</b> could not be written.</p>") |
996 "<p>The tasks file <b>{0}</b> could not be written.</p>") |
981 .format(fn)) |
997 .format(fn)) |
982 return |
998 return |
1010 @param quiet flag indicating quiet operations. |
1026 @param quiet flag indicating quiet operations. |
1011 If this flag is true, no errors are reported. |
1027 If this flag is true, no errors are reported. |
1012 """ |
1028 """ |
1013 if self.pfile is None: |
1029 if self.pfile is None: |
1014 if not quiet: |
1030 if not quiet: |
1015 E5MessageBox.critical(self.ui, |
1031 E5MessageBox.critical( |
|
1032 self.ui, |
1016 self.trUtf8("Read debugger properties"), |
1033 self.trUtf8("Read debugger properties"), |
1017 self.trUtf8("Please save the project first.")) |
1034 self.trUtf8("Please save the project first.")) |
1018 return |
1035 return |
1019 |
1036 |
1020 fn, ext = os.path.splitext(os.path.basename(self.pfile)) |
1037 fn, ext = os.path.splitext(os.path.basename(self.pfile)) |
1026 reader = DebuggerPropertiesReader(f, self) |
1043 reader = DebuggerPropertiesReader(f, self) |
1027 reader.readXML(quiet=quiet) |
1044 reader.readXML(quiet=quiet) |
1028 f.close() |
1045 f.close() |
1029 else: |
1046 else: |
1030 if not quiet: |
1047 if not quiet: |
1031 E5MessageBox.critical(self.ui, |
1048 E5MessageBox.critical( |
|
1049 self.ui, |
1032 self.trUtf8("Read debugger properties"), |
1050 self.trUtf8("Read debugger properties"), |
1033 self.trUtf8( |
1051 self.trUtf8( |
1034 "<p>The project debugger properties file <b>{0}</b>" |
1052 "<p>The project debugger properties file <b>{0}</b>" |
1035 " could not be read.</p>").format(fn)) |
1053 " could not be read.</p>").format(fn)) |
1036 |
1054 |
1041 @param quiet flag indicating quiet operations. |
1059 @param quiet flag indicating quiet operations. |
1042 If this flag is true, no errors are reported. |
1060 If this flag is true, no errors are reported. |
1043 """ |
1061 """ |
1044 if self.pfile is None: |
1062 if self.pfile is None: |
1045 if not quiet: |
1063 if not quiet: |
1046 E5MessageBox.critical(self.ui, |
1064 E5MessageBox.critical( |
|
1065 self.ui, |
1047 self.trUtf8("Save debugger properties"), |
1066 self.trUtf8("Save debugger properties"), |
1048 self.trUtf8("Please save the project first.")) |
1067 self.trUtf8("Please save the project first.")) |
1049 return |
1068 return |
1050 |
1069 |
1051 fn, ext = os.path.splitext(os.path.basename(self.pfile)) |
1070 fn, ext = os.path.splitext(os.path.basename(self.pfile)) |
1057 DebuggerPropertiesWriter( |
1076 DebuggerPropertiesWriter( |
1058 f, os.path.splitext(os.path.basename(fn))[0]).writeXML() |
1077 f, os.path.splitext(os.path.basename(fn))[0]).writeXML() |
1059 f.close() |
1078 f.close() |
1060 else: |
1079 else: |
1061 if not quiet: |
1080 if not quiet: |
1062 E5MessageBox.critical(self.ui, |
1081 E5MessageBox.critical( |
|
1082 self.ui, |
1063 self.trUtf8("Save debugger properties"), |
1083 self.trUtf8("Save debugger properties"), |
1064 self.trUtf8( |
1084 self.trUtf8( |
1065 "<p>The project debugger properties file <b>{0}</b>" |
1085 "<p>The project debugger properties file <b>{0}</b>" |
1066 " could not be written.</p>").format(fn)) |
1086 " could not be written.</p>").format(fn)) |
1067 |
1087 |
1068 def __deleteDebugProperties(self): |
1088 def __deleteDebugProperties(self): |
1069 """ |
1089 """ |
1070 Private method to delete the project debugger properties file (.e4d). |
1090 Private method to delete the project debugger properties file (.e4d). |
1071 """ |
1091 """ |
1072 if self.pfile is None: |
1092 if self.pfile is None: |
1073 E5MessageBox.critical(self.ui, |
1093 E5MessageBox.critical( |
|
1094 self.ui, |
1074 self.trUtf8("Delete debugger properties"), |
1095 self.trUtf8("Delete debugger properties"), |
1075 self.trUtf8("Please save the project first.")) |
1096 self.trUtf8("Please save the project first.")) |
1076 return |
1097 return |
1077 |
1098 |
1078 fname, ext = os.path.splitext(os.path.basename(self.pfile)) |
1099 fname, ext = os.path.splitext(os.path.basename(self.pfile)) |
1081 "{0}.e4d".format(fname))]: |
1102 "{0}.e4d".format(fname))]: |
1082 if os.path.exists(fn): |
1103 if os.path.exists(fn): |
1083 try: |
1104 try: |
1084 os.remove(fn) |
1105 os.remove(fn) |
1085 except OSError: |
1106 except OSError: |
1086 E5MessageBox.critical(self.ui, |
1107 E5MessageBox.critical( |
|
1108 self.ui, |
1087 self.trUtf8("Delete debugger properties"), |
1109 self.trUtf8("Delete debugger properties"), |
1088 self.trUtf8( |
1110 self.trUtf8( |
1089 "<p>The project debugger properties file" |
1111 "<p>The project debugger properties file" |
1090 " <b>{0}</b> could not be deleted.</p>") |
1112 " <b>{0}</b> could not be deleted.</p>") |
1091 .format(fn)) |
1113 .format(fn)) |
1176 """ |
1198 """ |
1177 Public slot used to add a language to the project. |
1199 Public slot used to add a language to the project. |
1178 """ |
1200 """ |
1179 if len(self.pdata["TRANSLATIONPATTERN"]) == 0 or \ |
1201 if len(self.pdata["TRANSLATIONPATTERN"]) == 0 or \ |
1180 self.pdata["TRANSLATIONPATTERN"][0] == '': |
1202 self.pdata["TRANSLATIONPATTERN"][0] == '': |
1181 E5MessageBox.critical(self.ui, |
1203 E5MessageBox.critical( |
|
1204 self.ui, |
1182 self.trUtf8("Add Language"), |
1205 self.trUtf8("Add Language"), |
1183 self.trUtf8( |
1206 self.trUtf8( |
1184 "You have to specify a translation pattern first.")) |
1207 "You have to specify a translation pattern first.")) |
1185 return |
1208 return |
1186 |
1209 |
1270 try: |
1293 try: |
1271 fn = os.path.join(self.ppath, langFile) |
1294 fn = os.path.join(self.ppath, langFile) |
1272 if os.path.exists(fn): |
1295 if os.path.exists(fn): |
1273 os.remove(fn) |
1296 os.remove(fn) |
1274 except IOError: |
1297 except IOError: |
1275 E5MessageBox.critical(self.ui, |
1298 E5MessageBox.critical( |
|
1299 self.ui, |
1276 self.trUtf8("Delete translation"), |
1300 self.trUtf8("Delete translation"), |
1277 self.trUtf8( |
1301 self.trUtf8( |
1278 "<p>The selected translation file <b>{0}</b> could not be" |
1302 "<p>The selected translation file <b>{0}</b> could not be" |
1279 " deleted.</p>").format(langFile)) |
1303 " deleted.</p>").format(langFile)) |
1280 return |
1304 return |
1290 os.path.basename(qmFile))) |
1314 os.path.basename(qmFile))) |
1291 fn = os.path.join(self.ppath, qmFile) |
1315 fn = os.path.join(self.ppath, qmFile) |
1292 if os.path.exists(fn): |
1316 if os.path.exists(fn): |
1293 os.remove(fn) |
1317 os.remove(fn) |
1294 except IOError: |
1318 except IOError: |
1295 E5MessageBox.critical(self.ui, |
1319 E5MessageBox.critical( |
|
1320 self.ui, |
1296 self.trUtf8("Delete translation"), |
1321 self.trUtf8("Delete translation"), |
1297 self.trUtf8( |
1322 self.trUtf8( |
1298 "<p>The selected translation file <b>{0}</b> could" |
1323 "<p>The selected translation file <b>{0}</b> could" |
1299 " not be deleted.</p>").format(qmFile)) |
1324 " not be deleted.</p>").format(qmFile)) |
1300 return |
1325 return |
1414 try: |
1439 try: |
1415 if not os.path.isdir(target): |
1440 if not os.path.isdir(target): |
1416 os.makedirs(target) |
1441 os.makedirs(target) |
1417 |
1442 |
1418 if os.path.exists(targetfile): |
1443 if os.path.exists(targetfile): |
1419 res = E5MessageBox.yesNo(self.ui, |
1444 res = E5MessageBox.yesNo( |
|
1445 self.ui, |
1420 self.trUtf8("Add file"), |
1446 self.trUtf8("Add file"), |
1421 self.trUtf8( |
1447 self.trUtf8( |
1422 "<p>The file <b>{0}</b> already" |
1448 "<p>The file <b>{0}</b> already" |
1423 " exists.</p><p>Overwrite it?</p>") |
1449 " exists.</p><p>Overwrite it?</p>") |
1424 .format(targetfile), |
1450 .format(targetfile), |
1426 if not res: |
1452 if not res: |
1427 return # don't overwrite |
1453 return # don't overwrite |
1428 |
1454 |
1429 shutil.copy(fn, target) |
1455 shutil.copy(fn, target) |
1430 except IOError as why: |
1456 except IOError as why: |
1431 E5MessageBox.critical(self.ui, |
1457 E5MessageBox.critical( |
|
1458 self.ui, |
1432 self.trUtf8("Add file"), |
1459 self.trUtf8("Add file"), |
1433 self.trUtf8( |
1460 self.trUtf8( |
1434 "<p>The selected file <b>{0}</b> could" |
1461 "<p>The selected file <b>{0}</b> could" |
1435 " not be added to <b>{1}</b>.</p>" |
1462 " not be added to <b>{1}</b>.</p>" |
1436 "<p>Reason: {2}</p>") |
1463 "<p>Reason: {2}</p>") |
1437 .format(fn, target, str(why))) |
1464 .format(fn, target, str(why))) |
1438 continue |
1465 continue |
1439 |
1466 |
1440 self.appendFile(targetfile, isSource or filter == 'source') |
1467 self.appendFile(targetfile, isSource or filter == 'source') |
1441 else: |
1468 else: |
1442 E5MessageBox.critical(self.ui, |
1469 E5MessageBox.critical( |
|
1470 self.ui, |
1443 self.trUtf8("Add file"), |
1471 self.trUtf8("Add file"), |
1444 self.trUtf8("The target directory must not be empty.")) |
1472 self.trUtf8("The target directory must not be empty.")) |
1445 |
1473 |
1446 def __addSingleDirectory(self, filetype, source, target, quiet=False): |
1474 def __addSingleDirectory(self, filetype, source, target, quiet=False): |
1447 """ |
1475 """ |
1467 sstring = "{0}{1}{2}".format(source, os.sep, pattern) |
1495 sstring = "{0}{1}{2}".format(source, os.sep, pattern) |
1468 files.extend(glob.glob(sstring)) |
1496 files.extend(glob.glob(sstring)) |
1469 |
1497 |
1470 if len(files) == 0: |
1498 if len(files) == 0: |
1471 if not quiet: |
1499 if not quiet: |
1472 E5MessageBox.information(self.ui, |
1500 E5MessageBox.information( |
|
1501 self.ui, |
1473 self.trUtf8("Add directory"), |
1502 self.trUtf8("Add directory"), |
1474 self.trUtf8("<p>The source directory doesn't contain" |
1503 self.trUtf8("<p>The source directory doesn't contain" |
1475 " any files belonging to the selected category.</p>")) |
1504 " any files belonging to the selected category.</p>")) |
1476 return |
1505 return |
1477 |
1506 |
1478 if not Utilities.samepath(target, source) and \ |
1507 if not Utilities.samepath(target, source) and \ |
1479 not os.path.isdir(target): |
1508 not os.path.isdir(target): |
1480 try: |
1509 try: |
1481 os.makedirs(target) |
1510 os.makedirs(target) |
1482 except IOError as why: |
1511 except IOError as why: |
1483 E5MessageBox.critical(self.ui, |
1512 E5MessageBox.critical( |
|
1513 self.ui, |
1484 self.trUtf8("Add directory"), |
1514 self.trUtf8("Add directory"), |
1485 self.trUtf8( |
1515 self.trUtf8( |
1486 "<p>The target directory <b>{0}</b> could not be" |
1516 "<p>The target directory <b>{0}</b> could not be" |
1487 " created.</p><p>Reason: {1}</p>") |
1517 " created.</p><p>Reason: {1}</p>") |
1488 .format(target, str(why))) |
1518 .format(target, str(why))) |
1495 |
1525 |
1496 targetfile = os.path.join(target, os.path.basename(file)) |
1526 targetfile = os.path.join(target, os.path.basename(file)) |
1497 if not Utilities.samepath(target, source): |
1527 if not Utilities.samepath(target, source): |
1498 try: |
1528 try: |
1499 if os.path.exists(targetfile): |
1529 if os.path.exists(targetfile): |
1500 res = E5MessageBox.yesNo(self.ui, |
1530 res = E5MessageBox.yesNo( |
|
1531 self.ui, |
1501 self.trUtf8("Add directory"), |
1532 self.trUtf8("Add directory"), |
1502 self.trUtf8( |
1533 self.trUtf8( |
1503 "<p>The file <b>{0}</b> already exists.</p>" |
1534 "<p>The file <b>{0}</b> already exists.</p>" |
1504 "<p>Overwrite it?</p>") |
1535 "<p>Overwrite it?</p>") |
1505 .format(targetfile), |
1536 .format(targetfile), |
1548 dlg = AddDirectoryDialog( |
1579 dlg = AddDirectoryDialog( |
1549 self, filter, self.parent(), startdir=startdir) |
1580 self, filter, self.parent(), startdir=startdir) |
1550 if dlg.exec_() == QDialog.Accepted: |
1581 if dlg.exec_() == QDialog.Accepted: |
1551 filetype, source, target, recursive = dlg.getData() |
1582 filetype, source, target, recursive = dlg.getData() |
1552 if target == '': |
1583 if target == '': |
1553 E5MessageBox.critical(self.ui, |
1584 E5MessageBox.critical( |
|
1585 self.ui, |
1554 self.trUtf8("Add directory"), |
1586 self.trUtf8("Add directory"), |
1555 self.trUtf8("The target directory must not be empty.")) |
1587 self.trUtf8("The target directory must not be empty.")) |
1556 return |
1588 return |
1557 |
1589 |
1558 if filetype == 'OTHERS': |
1590 if filetype == 'OTHERS': |
1559 self.addToOthers(source) |
1591 self.addToOthers(source) |
1560 return |
1592 return |
1561 |
1593 |
1562 if source == '': |
1594 if source == '': |
1563 E5MessageBox.critical(self.ui, |
1595 E5MessageBox.critical( |
|
1596 self.ui, |
1564 self.trUtf8("Add directory"), |
1597 self.trUtf8("Add directory"), |
1565 self.trUtf8("The source directory must not be empty.")) |
1598 self.trUtf8("The source directory must not be empty.")) |
1566 return |
1599 return |
1567 |
1600 |
1568 if recursive: |
1601 if recursive: |
1692 if not newfn: |
1725 if not newfn: |
1693 return False |
1726 return False |
1694 newfn = Utilities.toNativeSeparators(newfn) |
1727 newfn = Utilities.toNativeSeparators(newfn) |
1695 |
1728 |
1696 if os.path.exists(newfn): |
1729 if os.path.exists(newfn): |
1697 res = E5MessageBox.yesNo(self.ui, |
1730 res = E5MessageBox.yesNo( |
|
1731 self.ui, |
1698 self.trUtf8("Rename File"), |
1732 self.trUtf8("Rename File"), |
1699 self.trUtf8("""<p>The file <b>{0}</b> already exists.""" |
1733 self.trUtf8("""<p>The file <b>{0}</b> already exists.""" |
1700 """ Overwrite it?</p>""") |
1734 """ Overwrite it?</p>""") |
1701 .format(newfn), |
1735 .format(newfn), |
1702 icon=E5MessageBox.Warning) |
1736 icon=E5MessageBox.Warning) |
1704 return False |
1738 return False |
1705 |
1739 |
1706 try: |
1740 try: |
1707 os.rename(oldfn, newfn) |
1741 os.rename(oldfn, newfn) |
1708 except OSError as msg: |
1742 except OSError as msg: |
1709 E5MessageBox.critical(self.ui, |
1743 E5MessageBox.critical( |
|
1744 self.ui, |
1710 self.trUtf8("Rename File"), |
1745 self.trUtf8("Rename File"), |
1711 self.trUtf8( |
1746 self.trUtf8( |
1712 """<p>The file <b>{0}</b> could not be renamed.<br />""" |
1747 """<p>The file <b>{0}</b> could not be renamed.<br />""" |
1713 """Reason: {1}</p>""").format(oldfn, str(msg))) |
1748 """Reason: {1}</p>""").format(oldfn, str(msg))) |
1714 return False |
1749 return False |
1895 self.ppath, head, |
1930 self.ppath, head, |
1896 "__pycache__", "{0}.*{1}".format(tail, ext)) |
1931 "__pycache__", "{0}.*{1}".format(tail, ext)) |
1897 for f in glob.glob(pat): |
1932 for f in glob.glob(pat): |
1898 os.remove(f) |
1933 os.remove(f) |
1899 except EnvironmentError: |
1934 except EnvironmentError: |
1900 E5MessageBox.critical(self.ui, |
1935 E5MessageBox.critical( |
|
1936 self.ui, |
1901 self.trUtf8("Delete file"), |
1937 self.trUtf8("Delete file"), |
1902 self.trUtf8( |
1938 self.trUtf8( |
1903 "<p>The selected file <b>{0}</b> could not be" |
1939 "<p>The selected file <b>{0}</b> could not be" |
1904 " deleted.</p>").format(fn)) |
1940 " deleted.</p>").format(fn)) |
1905 return False |
1941 return False |
1919 if not os.path.isabs(dn): |
1955 if not os.path.isabs(dn): |
1920 dn = os.path.join(self.ppath, dn) |
1956 dn = os.path.join(self.ppath, dn) |
1921 try: |
1957 try: |
1922 shutil.rmtree(dn, True) |
1958 shutil.rmtree(dn, True) |
1923 except EnvironmentError: |
1959 except EnvironmentError: |
1924 E5MessageBox.critical(self.ui, |
1960 E5MessageBox.critical( |
|
1961 self.ui, |
1925 self.trUtf8("Delete directory"), |
1962 self.trUtf8("Delete directory"), |
1926 self.trUtf8("<p>The selected directory <b>{0}</b> could not be" |
1963 self.trUtf8("<p>The selected directory <b>{0}</b> could not be" |
1927 " deleted.</p>").format(dn)) |
1964 " deleted.</p>").format(dn)) |
1928 return False |
1965 return False |
1929 |
1966 |
2000 # create the project directory if it doesn't exist already |
2037 # create the project directory if it doesn't exist already |
2001 if not os.path.isdir(self.ppath): |
2038 if not os.path.isdir(self.ppath): |
2002 try: |
2039 try: |
2003 os.makedirs(self.ppath) |
2040 os.makedirs(self.ppath) |
2004 except EnvironmentError: |
2041 except EnvironmentError: |
2005 E5MessageBox.critical(self.ui, |
2042 E5MessageBox.critical( |
|
2043 self.ui, |
2006 self.trUtf8("Create project directory"), |
2044 self.trUtf8("Create project directory"), |
2007 self.trUtf8( |
2045 self.trUtf8( |
2008 "<p>The project directory <b>{0}</b> could not" |
2046 "<p>The project directory <b>{0}</b> could not" |
2009 " be created.</p>") |
2047 " be created.</p>") |
2010 .format(self.ppath)) |
2048 .format(self.ppath)) |
2057 if not os.path.exists(ms): |
2095 if not os.path.exists(ms): |
2058 try: |
2096 try: |
2059 f = open(ms, "w") |
2097 f = open(ms, "w") |
2060 f.close() |
2098 f.close() |
2061 except IOError as err: |
2099 except IOError as err: |
2062 E5MessageBox.critical(self.ui, |
2100 E5MessageBox.critical( |
|
2101 self.ui, |
2063 self.trUtf8("Create main script"), |
2102 self.trUtf8("Create main script"), |
2064 self.trUtf8( |
2103 self.trUtf8( |
2065 "<p>The mainscript <b>{0}</b> could not" |
2104 "<p>The mainscript <b>{0}</b> could not" |
2066 " be created.<br/>Reason: {1}</p>") |
2105 " be created.<br/>Reason: {1}</p>") |
2067 .format(self.ppath, str(err))) |
2106 .format(self.ppath, str(err))) |
2068 self.appendFile(ms) |
2107 self.appendFile(ms) |
2069 except IndexError: |
2108 except IndexError: |
2070 ms = "" |
2109 ms = "" |
2071 |
2110 |
2072 # add existing files to the project |
2111 # add existing files to the project |
2073 res = E5MessageBox.yesNo(self.ui, |
2112 res = E5MessageBox.yesNo( |
|
2113 self.ui, |
2074 self.trUtf8("New Project"), |
2114 self.trUtf8("New Project"), |
2075 self.trUtf8("""Add existing files to the project?"""), |
2115 self.trUtf8("""Add existing files to the project?"""), |
2076 yesDefault=True) |
2116 yesDefault=True) |
2077 if res: |
2117 if res: |
2078 self.newProjectAddFiles(ms) |
2118 self.newProjectAddFiles(ms) |
2117 self.pdata["VCS"] = [vcsSystem] |
2157 self.pdata["VCS"] = [vcsSystem] |
2118 self.vcs = self.initVCS() |
2158 self.vcs = self.initVCS() |
2119 self.setDirty(True) |
2159 self.setDirty(True) |
2120 if self.vcs is not None: |
2160 if self.vcs is not None: |
2121 # edit VCS command options |
2161 # edit VCS command options |
2122 vcores = E5MessageBox.yesNo(self.ui, |
2162 vcores = E5MessageBox.yesNo( |
|
2163 self.ui, |
2123 self.trUtf8("New Project"), |
2164 self.trUtf8("New Project"), |
2124 self.trUtf8( |
2165 self.trUtf8( |
2125 """Would you like to edit the VCS""" |
2166 """Would you like to edit the VCS""" |
2126 """ command options?""")) |
2167 """ command options?""")) |
2127 if vcores: |
2168 if vcores: |
2130 codlg = vcsCommandOptionsDialog(self.vcs) |
2171 codlg = vcsCommandOptionsDialog(self.vcs) |
2131 if codlg.exec_() == QDialog.Accepted: |
2172 if codlg.exec_() == QDialog.Accepted: |
2132 self.vcs.vcsSetOptions(codlg.getOptions()) |
2173 self.vcs.vcsSetOptions(codlg.getOptions()) |
2133 # add project file to repository |
2174 # add project file to repository |
2134 if res == 0: |
2175 if res == 0: |
2135 apres = E5MessageBox.yesNo(self.ui, |
2176 apres = E5MessageBox.yesNo( |
|
2177 self.ui, |
2136 self.trUtf8("New project"), |
2178 self.trUtf8("New project"), |
2137 self.trUtf8( |
2179 self.trUtf8( |
2138 "Shall the project file be added" |
2180 "Shall the project file be added" |
2139 " to the repository?"), |
2181 " to the repository?"), |
2140 yesDefault=True) |
2182 yesDefault=True) |
2180 self.pdata["VCS"] = ['None'] |
2222 self.pdata["VCS"] = ['None'] |
2181 self.vcs = self.initVCS() |
2223 self.vcs = self.initVCS() |
2182 self.setDirty(True) |
2224 self.setDirty(True) |
2183 if self.vcs is not None: |
2225 if self.vcs is not None: |
2184 # edit VCS command options |
2226 # edit VCS command options |
2185 vcores = E5MessageBox.yesNo(self.ui, |
2227 vcores = E5MessageBox.yesNo( |
|
2228 self.ui, |
2186 self.trUtf8("New Project"), |
2229 self.trUtf8("New Project"), |
2187 self.trUtf8( |
2230 self.trUtf8( |
2188 """Would you like to edit the VCS command""" |
2231 """Would you like to edit the VCS command""" |
2189 """ options?""")) |
2232 """ options?""")) |
2190 if vcores: |
2233 if vcores: |
2638 if not ext: |
2681 if not ext: |
2639 ex = selectedFilter.split("(*")[1].split(")")[0] |
2682 ex = selectedFilter.split("(*")[1].split(")")[0] |
2640 if ex: |
2683 if ex: |
2641 fn += ex |
2684 fn += ex |
2642 if QFileInfo(fn).exists(): |
2685 if QFileInfo(fn).exists(): |
2643 res = E5MessageBox.yesNo(self.ui, |
2686 res = E5MessageBox.yesNo( |
|
2687 self.ui, |
2644 self.trUtf8("Save File"), |
2688 self.trUtf8("Save File"), |
2645 self.trUtf8("""<p>The file <b>{0}</b> already exists.""" |
2689 self.trUtf8("""<p>The file <b>{0}</b> already exists.""" |
2646 """ Overwrite it?</p>""").format(fn), |
2690 """ Overwrite it?</p>""").format(fn), |
2647 icon=E5MessageBox.Warning) |
2691 icon=E5MessageBox.Warning) |
2648 if not res: |
2692 if not res: |
2675 Public method to check dirty status and open a message window. |
2719 Public method to check dirty status and open a message window. |
2676 |
2720 |
2677 @return flag indicating whether this operation was successful (boolean) |
2721 @return flag indicating whether this operation was successful (boolean) |
2678 """ |
2722 """ |
2679 if self.isDirty(): |
2723 if self.isDirty(): |
2680 res = E5MessageBox.okToClearData(self.parent(), |
2724 res = E5MessageBox.okToClearData( |
|
2725 self.parent(), |
2681 self.trUtf8("Close Project"), |
2726 self.trUtf8("Close Project"), |
2682 self.trUtf8("The current project has unsaved changes."), |
2727 self.trUtf8("The current project has unsaved changes."), |
2683 self.saveProject) |
2728 self.saveProject) |
2684 if res: |
2729 if res: |
2685 self.setDirty(False) |
2730 self.setDirty(False) |
2804 success &= vm.saveEditorEd(editor) |
2849 success &= vm.saveEditorEd(editor) |
2805 if reportSyntaxErrors and editor.hasSyntaxErrors(): |
2850 if reportSyntaxErrors and editor.hasSyntaxErrors(): |
2806 filesWithSyntaxErrors += 1 |
2851 filesWithSyntaxErrors += 1 |
2807 |
2852 |
2808 if reportSyntaxErrors and filesWithSyntaxErrors > 0: |
2853 if reportSyntaxErrors and filesWithSyntaxErrors > 0: |
2809 E5MessageBox.critical(self.ui, |
2854 E5MessageBox.critical( |
|
2855 self.ui, |
2810 self.trUtf8("Syntax errors detected"), |
2856 self.trUtf8("Syntax errors detected"), |
2811 self.trUtf8( |
2857 self.trUtf8( |
2812 """The project contains %n file(s) with syntax errors.""", |
2858 """The project contains %n file(s) with syntax errors.""", |
2813 "", filesWithSyntaxErrors) |
2859 "", filesWithSyntaxErrors) |
2814 ) |
2860 ) |
2835 success &= editor.checkDirty() |
2881 success &= editor.checkDirty() |
2836 if reportSyntaxErrors and editor.hasSyntaxErrors(): |
2882 if reportSyntaxErrors and editor.hasSyntaxErrors(): |
2837 filesWithSyntaxErrors += 1 |
2883 filesWithSyntaxErrors += 1 |
2838 |
2884 |
2839 if reportSyntaxErrors and filesWithSyntaxErrors > 0: |
2885 if reportSyntaxErrors and filesWithSyntaxErrors > 0: |
2840 E5MessageBox.critical(self.ui, |
2886 E5MessageBox.critical( |
|
2887 self.ui, |
2841 self.trUtf8("Syntax errors detected"), |
2888 self.trUtf8("Syntax errors detected"), |
2842 self.trUtf8( |
2889 self.trUtf8( |
2843 """The project contains %n file(s) with syntax errors.""", |
2890 """The project contains %n file(s) with syntax errors.""", |
2844 "", filesWithSyntaxErrors) |
2891 "", filesWithSyntaxErrors) |
2845 ) |
2892 ) |
3921 return |
3968 return |
3922 |
3969 |
3923 # if newfiles is empty, put up message box informing user nothing found |
3970 # if newfiles is empty, put up message box informing user nothing found |
3924 if not newFiles: |
3971 if not newFiles: |
3925 if onUserDemand: |
3972 if onUserDemand: |
3926 E5MessageBox.information(self.ui, |
3973 E5MessageBox.information( |
|
3974 self.ui, |
3927 self.trUtf8("Search New Files"), |
3975 self.trUtf8("Search New Files"), |
3928 self.trUtf8("There were no new files found to be added.")) |
3976 self.trUtf8("There were no new files found to be added.")) |
3929 return |
3977 return |
3930 |
3978 |
3931 # autoInclude is not set, show a dialog |
3979 # autoInclude is not set, show a dialog |
4055 vcsExists, msg = vcs.vcsExists() |
4103 vcsExists, msg = vcs.vcsExists() |
4056 if not vcsExists: |
4104 if not vcsExists: |
4057 if override: |
4105 if override: |
4058 # override failed, revert to original |
4106 # override failed, revert to original |
4059 QApplication.restoreOverrideCursor() |
4107 QApplication.restoreOverrideCursor() |
4060 E5MessageBox.critical(self.ui, |
4108 E5MessageBox.critical( |
|
4109 self.ui, |
4061 self.trUtf8("Version Control System"), |
4110 self.trUtf8("Version Control System"), |
4062 self.trUtf8( |
4111 self.trUtf8( |
4063 "<p>The selected VCS <b>{0}</b> could not be" |
4112 "<p>The selected VCS <b>{0}</b> could not be" |
4064 " found. <br/>Reverting override.</p><p>{1}</p>") |
4113 " found. <br/>Reverting override.</p><p>{1}</p>") |
4065 .format(vcsSystem, msg)) |
4114 .format(vcsSystem, msg)) |
4066 self.pudata["VCSOVERRIDE"] = [] |
4115 self.pudata["VCSOVERRIDE"] = [] |
4067 return self.initVCS(nooverride=True) |
4116 return self.initVCS(nooverride=True) |
4068 |
4117 |
4069 QApplication.restoreOverrideCursor() |
4118 QApplication.restoreOverrideCursor() |
4070 E5MessageBox.critical(self.ui, |
4119 E5MessageBox.critical( |
|
4120 self.ui, |
4071 self.trUtf8("Version Control System"), |
4121 self.trUtf8("Version Control System"), |
4072 self.trUtf8( |
4122 self.trUtf8( |
4073 "<p>The selected VCS <b>{0}</b> could not be" |
4123 "<p>The selected VCS <b>{0}</b> could not be" |
4074 " found.<br/>Disabling version control.</p>" |
4124 " found.<br/>Disabling version control.</p>" |
4075 "<p>{1}</p>").format(vcsSystem, msg)) |
4125 "<p>{1}</p>").format(vcsSystem, msg)) |
4181 Private slot used to show the code coverage information for the |
4231 Private slot used to show the code coverage information for the |
4182 project files. |
4232 project files. |
4183 """ |
4233 """ |
4184 fn = self.getMainScript(True) |
4234 fn = self.getMainScript(True) |
4185 if fn is None: |
4235 if fn is None: |
4186 E5MessageBox.critical(self.ui, |
4236 E5MessageBox.critical( |
|
4237 self.ui, |
4187 self.trUtf8("Coverage Data"), |
4238 self.trUtf8("Coverage Data"), |
4188 self.trUtf8("There is no main script defined for the" |
4239 self.trUtf8("There is no main script defined for the" |
4189 " current project. Aborting")) |
4240 " current project. Aborting")) |
4190 return |
4241 return |
4191 |
4242 |
4228 """ |
4279 """ |
4229 Private slot used to show the profiling information for the project. |
4280 Private slot used to show the profiling information for the project. |
4230 """ |
4281 """ |
4231 fn = self.getMainScript(True) |
4282 fn = self.getMainScript(True) |
4232 if fn is None: |
4283 if fn is None: |
4233 E5MessageBox.critical(self.ui, |
4284 E5MessageBox.critical( |
|
4285 self.ui, |
4234 self.trUtf8("Profile Data"), |
4286 self.trUtf8("Profile Data"), |
4235 self.trUtf8("There is no main script defined for the" |
4287 self.trUtf8("There is no main script defined for the" |
4236 " current project. Aborting")) |
4288 " current project. Aborting")) |
4237 return |
4289 return |
4238 |
4290 |
4303 |
4355 |
4304 def handleApplicationDiagram(self): |
4356 def handleApplicationDiagram(self): |
4305 """ |
4357 """ |
4306 Private method to handle the application diagram context menu action. |
4358 Private method to handle the application diagram context menu action. |
4307 """ |
4359 """ |
4308 res = E5MessageBox.yesNo(self.ui, |
4360 res = E5MessageBox.yesNo( |
|
4361 self.ui, |
4309 self.trUtf8("Application Diagram"), |
4362 self.trUtf8("Application Diagram"), |
4310 self.trUtf8("""Include module names?"""), |
4363 self.trUtf8("""Include module names?"""), |
4311 yesDefault=True) |
4364 yesDefault=True) |
4312 |
4365 |
4313 from Graphics.UMLDialog import UMLDialog |
4366 from Graphics.UMLDialog import UMLDialog |
4420 """ |
4473 """ |
4421 Private slot to create a PKGLIST file needed for archive file creation. |
4474 Private slot to create a PKGLIST file needed for archive file creation. |
4422 """ |
4475 """ |
4423 pkglist = os.path.join(self.ppath, "PKGLIST") |
4476 pkglist = os.path.join(self.ppath, "PKGLIST") |
4424 if os.path.exists(pkglist): |
4477 if os.path.exists(pkglist): |
4425 res = E5MessageBox.yesNo(self.ui, |
4478 res = E5MessageBox.yesNo( |
|
4479 self.ui, |
4426 self.trUtf8("Create Package List"), |
4480 self.trUtf8("Create Package List"), |
4427 self.trUtf8("<p>The file <b>PKGLIST</b> already" |
4481 self.trUtf8("<p>The file <b>PKGLIST</b> already" |
4428 " exists.</p><p>Overwrite it?</p>"), |
4482 " exists.</p><p>Overwrite it?</p>"), |
4429 icon=E5MessageBox.Warning) |
4483 icon=E5MessageBox.Warning) |
4430 if not res: |
4484 if not res: |
4457 pkglistFile.write( |
4511 pkglistFile.write( |
4458 "\n".join([Utilities.fromNativeSeparators(f) for f in lst])) |
4512 "\n".join([Utilities.fromNativeSeparators(f) for f in lst])) |
4459 pkglistFile.write("\n") # ensure the file ends with an empty line |
4513 pkglistFile.write("\n") # ensure the file ends with an empty line |
4460 pkglistFile.close() |
4514 pkglistFile.close() |
4461 except IOError as why: |
4515 except IOError as why: |
4462 E5MessageBox.critical(self.ui, |
4516 E5MessageBox.critical( |
|
4517 self.ui, |
4463 self.trUtf8("Create Package List"), |
4518 self.trUtf8("Create Package List"), |
4464 self.trUtf8( |
4519 self.trUtf8( |
4465 """<p>The file <b>PKGLIST</b> could not be created.</p>""" |
4520 """<p>The file <b>PKGLIST</b> could not be created.</p>""" |
4466 """<p>Reason: {0}</p>""").format(str(why))) |
4521 """<p>Reason: {0}</p>""").format(str(why))) |
4467 return |
4522 return |
4475 |
4530 |
4476 @param snapshot flag indicating a snapshot archive (boolean) |
4531 @param snapshot flag indicating a snapshot archive (boolean) |
4477 """ |
4532 """ |
4478 pkglist = os.path.join(self.ppath, "PKGLIST") |
4533 pkglist = os.path.join(self.ppath, "PKGLIST") |
4479 if not os.path.exists(pkglist): |
4534 if not os.path.exists(pkglist): |
4480 E5MessageBox.critical(self.ui, |
4535 E5MessageBox.critical( |
|
4536 self.ui, |
4481 self.trUtf8("Create Plugin Archive"), |
4537 self.trUtf8("Create Plugin Archive"), |
4482 self.trUtf8("""<p>The file <b>PKGLIST</b> does not exist. """ |
4538 self.trUtf8("""<p>The file <b>PKGLIST</b> does not exist. """ |
4483 """Aborting...</p>""")) |
4539 """Aborting...</p>""")) |
4484 return |
4540 return |
4485 |
4541 |
4486 if len(self.pdata["MAINSCRIPT"]) == 0 or \ |
4542 if len(self.pdata["MAINSCRIPT"]) == 0 or \ |
4487 len(self.pdata["MAINSCRIPT"][0]) == 0: |
4543 len(self.pdata["MAINSCRIPT"][0]) == 0: |
4488 E5MessageBox.critical(self.ui, |
4544 E5MessageBox.critical( |
|
4545 self.ui, |
4489 self.trUtf8("Create Plugin Archive"), |
4546 self.trUtf8("Create Plugin Archive"), |
4490 self.trUtf8( |
4547 self.trUtf8( |
4491 """The project does not have a main script defined. """ |
4548 """The project does not have a main script defined. """ |
4492 """Aborting...""")) |
4549 """Aborting...""")) |
4493 return |
4550 return |
4496 pkglistFile = open(pkglist, "r", encoding="utf-8") |
4553 pkglistFile = open(pkglist, "r", encoding="utf-8") |
4497 names = pkglistFile.read() |
4554 names = pkglistFile.read() |
4498 pkglistFile.close() |
4555 pkglistFile.close() |
4499 names = sorted(names.splitlines()) |
4556 names = sorted(names.splitlines()) |
4500 except IOError as why: |
4557 except IOError as why: |
4501 E5MessageBox.critical(self.ui, |
4558 E5MessageBox.critical( |
|
4559 self.ui, |
4502 self.trUtf8("Create Plugin Archive"), |
4560 self.trUtf8("Create Plugin Archive"), |
4503 self.trUtf8( |
4561 self.trUtf8( |
4504 """<p>The file <b>PKGLIST</b> could not be read.</p>""" |
4562 """<p>The file <b>PKGLIST</b> could not be read.</p>""" |
4505 """<p>Reason: {0}</p>""").format(str(why))) |
4563 """<p>Reason: {0}</p>""").format(str(why))) |
4506 return |
4564 return |
4508 archive = os.path.join( |
4566 archive = os.path.join( |
4509 self.ppath, self.pdata["MAINSCRIPT"][0].replace(".py", ".zip")) |
4567 self.ppath, self.pdata["MAINSCRIPT"][0].replace(".py", ".zip")) |
4510 try: |
4568 try: |
4511 archiveFile = zipfile.ZipFile(archive, "w") |
4569 archiveFile = zipfile.ZipFile(archive, "w") |
4512 except IOError as why: |
4570 except IOError as why: |
4513 E5MessageBox.critical(self.ui, |
4571 E5MessageBox.critical( |
|
4572 self.ui, |
4514 self.trUtf8("Create Plugin Archive"), |
4573 self.trUtf8("Create Plugin Archive"), |
4515 self.trUtf8( |
4574 self.trUtf8( |
4516 """<p>The eric5 plugin archive file <b>{0}</b> could """ |
4575 """<p>The eric5 plugin archive file <b>{0}</b> could """ |
4517 """not be created.</p>""" |
4576 """not be created.</p>""" |
4518 """<p>Reason: {1}</p>""").format(archive, str(why))) |
4577 """<p>Reason: {1}</p>""").format(archive, str(why))) |
4533 if name == self.pdata["MAINSCRIPT"][0]: |
4592 if name == self.pdata["MAINSCRIPT"][0]: |
4534 version = self.__pluginExtractVersion( |
4593 version = self.__pluginExtractVersion( |
4535 os.path.join(self.ppath, |
4594 os.path.join(self.ppath, |
4536 self.pdata["MAINSCRIPT"][0])) |
4595 self.pdata["MAINSCRIPT"][0])) |
4537 except OSError as why: |
4596 except OSError as why: |
4538 E5MessageBox.critical(self.ui, |
4597 E5MessageBox.critical( |
|
4598 self.ui, |
4539 self.trUtf8("Create Plugin Archive"), |
4599 self.trUtf8("Create Plugin Archive"), |
4540 self.trUtf8( |
4600 self.trUtf8( |
4541 """<p>The file <b>{0}</b> could not be stored """ |
4601 """<p>The file <b>{0}</b> could not be stored """ |
4542 """in the archive. Ignoring it.</p>""" |
4602 """in the archive. Ignoring it.</p>""" |
4543 """<p>Reason: {1}</p>""")\ |
4603 """<p>Reason: {1}</p>""")\ |
4555 self.trUtf8( |
4615 self.trUtf8( |
4556 """<p>The eric5 plugin archive file <b>{0}</b> was """ |
4616 """<p>The eric5 plugin archive file <b>{0}</b> was """ |
4557 """created successfully.</p>""")\ |
4617 """created successfully.</p>""")\ |
4558 .format(os.path.basename(archive))) |
4618 .format(os.path.basename(archive))) |
4559 else: |
4619 else: |
4560 E5MessageBox.information(self.ui, |
4620 E5MessageBox.information( |
|
4621 self.ui, |
4561 self.trUtf8("Create Plugin Archive"), |
4622 self.trUtf8("Create Plugin Archive"), |
4562 self.trUtf8( |
4623 self.trUtf8( |
4563 """<p>The eric5 plugin archive file <b>{0}</b> was """ |
4624 """<p>The eric5 plugin archive file <b>{0}</b> was """ |
4564 """created successfully.</p>""").format(archive)) |
4625 """created successfully.</p>""").format(archive)) |
4565 |
4626 |
4599 """ |
4660 """ |
4600 try: |
4661 try: |
4601 sourcelines, encoding = Utilities.readEncodedFile(filename) |
4662 sourcelines, encoding = Utilities.readEncodedFile(filename) |
4602 sourcelines = sourcelines.splitlines(True) |
4663 sourcelines = sourcelines.splitlines(True) |
4603 except (IOError, UnicodeError) as why: |
4664 except (IOError, UnicodeError) as why: |
4604 E5MessageBox.critical(self.ui, |
4665 E5MessageBox.critical( |
|
4666 self.ui, |
4605 self.trUtf8("Create Plugin Archive"), |
4667 self.trUtf8("Create Plugin Archive"), |
4606 self.trUtf8("""<p>The plugin file <b>{0}</b> could """ |
4668 self.trUtf8("""<p>The plugin file <b>{0}</b> could """ |
4607 """not be read.</p>""" |
4669 """not be read.</p>""" |
4608 """<p>Reason: {1}</p>""") |
4670 """<p>Reason: {1}</p>""") |
4609 .format(filename, str(why))) |
4671 .format(filename, str(why))) |
4638 version = "0.0.0" |
4700 version = "0.0.0" |
4639 try: |
4701 try: |
4640 sourcelines = Utilities.readEncodedFile(filename)[0] |
4702 sourcelines = Utilities.readEncodedFile(filename)[0] |
4641 sourcelines = sourcelines.splitlines(True) |
4703 sourcelines = sourcelines.splitlines(True) |
4642 except (IOError, UnicodeError) as why: |
4704 except (IOError, UnicodeError) as why: |
4643 E5MessageBox.critical(self.ui, |
4705 E5MessageBox.critical( |
|
4706 self.ui, |
4644 self.trUtf8("Create Plugin Archive"), |
4707 self.trUtf8("Create Plugin Archive"), |
4645 self.trUtf8( |
4708 self.trUtf8( |
4646 """<p>The plugin file <b>{0}</b> could """ |
4709 """<p>The plugin file <b>{0}</b> could """ |
4647 """not be read.</p> <p>Reason: {1}</p>""") |
4710 """not be read.</p> <p>Reason: {1}</p>""") |
4648 .format(filename, str(why))) |
4711 .format(filename, str(why))) |