273 @keyparam lexerAssociationCallback reference to a method returning the |
273 @keyparam lexerAssociationCallback reference to a method returning the |
274 lexer type to be used for syntax highlighting given the name of |
274 lexer type to be used for syntax highlighting given the name of |
275 a file |
275 a file |
276 """ |
276 """ |
277 if type_ in self.__projectTypes: |
277 if type_ in self.__projectTypes: |
278 QMessageBox.critical(None, |
278 E5MessageBox.critical(self.ui, |
279 self.trUtf8("Registering Project Type"), |
279 self.trUtf8("Registering Project Type"), |
280 self.trUtf8("""<p>The Project type <b>{0}</b> already exists.</p>""")\ |
280 self.trUtf8("""<p>The Project type <b>{0}</b> already exists.</p>""")\ |
281 .format(type_) |
281 .format(type_) |
282 ) |
282 ) |
283 else: |
283 else: |
577 if fn.lower().endswith("e4pz"): |
577 if fn.lower().endswith("e4pz"): |
578 try: |
578 try: |
579 import gzip |
579 import gzip |
580 except ImportError: |
580 except ImportError: |
581 QApplication.restoreOverrideCursor() |
581 QApplication.restoreOverrideCursor() |
582 QMessageBox.critical(None, |
582 E5MessageBox.critical(self.ui, |
583 self.trUtf8("Read project file"), |
583 self.trUtf8("Read project file"), |
584 self.trUtf8("""Compressed project files not supported.""" |
584 self.trUtf8("""Compressed project files not supported.""" |
585 """ The compression library is missing.""")) |
585 """ The compression library is missing.""")) |
586 return False |
586 return False |
587 g = gzip.open(fn, "rb") |
587 g = gzip.open(fn, "rb") |
592 line = f.readline() |
592 line = f.readline() |
593 dtdLine = f.readline() |
593 dtdLine = f.readline() |
594 f.close() |
594 f.close() |
595 except EnvironmentError: |
595 except EnvironmentError: |
596 QApplication.restoreOverrideCursor() |
596 QApplication.restoreOverrideCursor() |
597 QMessageBox.critical(None, |
597 E5MessageBox.critical(self.ui, |
598 self.trUtf8("Read project file"), |
598 self.trUtf8("Read project file"), |
599 self.trUtf8("<p>The project file <b>{0}</b> could not be read.</p>")\ |
599 self.trUtf8("<p>The project file <b>{0}</b> could not be read.</p>")\ |
600 .format(fn)) |
600 .format(fn)) |
601 return False |
601 return False |
602 |
602 |
611 self.__syncRecent() |
611 self.__syncRecent() |
612 |
612 |
613 # now read the file |
613 # now read the file |
614 if not line.startswith('<?xml'): |
614 if not line.startswith('<?xml'): |
615 QApplication.restoreOverrideCursor() |
615 QApplication.restoreOverrideCursor() |
616 QMessageBox.critical(None, |
616 E5MessageBox.critical(self.ui, |
617 self.trUtf8("Read project file"), |
617 self.trUtf8("Read project file"), |
618 self.trUtf8("<p>The project file <b>{0}</b> has an unsupported" |
618 self.trUtf8("<p>The project file <b>{0}</b> has an unsupported" |
619 " format.</p>").format(fn)) |
619 " format.</p>").format(fn)) |
620 return False |
620 return False |
621 |
621 |
695 if fn.lower().endswith("e4pz"): |
695 if fn.lower().endswith("e4pz"): |
696 try: |
696 try: |
697 import gzip |
697 import gzip |
698 except ImportError: |
698 except ImportError: |
699 QApplication.restoreOverrideCursor() |
699 QApplication.restoreOverrideCursor() |
700 QMessageBox.critical(None, |
700 E5MessageBox.critical(self.ui, |
701 self.trUtf8("Read project file"), |
701 self.trUtf8("Read project file"), |
702 self.trUtf8("""Compressed project files not supported.""" |
702 self.trUtf8("""Compressed project files not supported.""" |
703 """ The compression library is missing.""")) |
703 """ The compression library is missing.""")) |
704 return False |
704 return False |
705 g = gzip.open(fn, "rb") |
705 g = gzip.open(fn, "rb") |
716 parser.parse(buf) |
716 parser.parse(buf) |
717 finally: |
717 finally: |
718 f.close() |
718 f.close() |
719 except IOError: |
719 except IOError: |
720 QApplication.restoreOverrideCursor() |
720 QApplication.restoreOverrideCursor() |
721 QMessageBox.critical(None, |
721 E5MessageBox.critical(self.ui, |
722 self.trUtf8("Read project file"), |
722 self.trUtf8("Read project file"), |
723 self.trUtf8("<p>The project file <b>{0}</b> could not be read.</p>")\ |
723 self.trUtf8("<p>The project file <b>{0}</b> could not be read.</p>")\ |
724 .format(fn)) |
724 .format(fn)) |
725 return False |
725 return False |
726 except XMLFatalParseError: |
726 except XMLFatalParseError: |
727 QApplication.restoreOverrideCursor() |
727 QApplication.restoreOverrideCursor() |
728 QMessageBox.critical(None, |
728 E5MessageBox.critical(self.ui, |
729 self.trUtf8("Read project file"), |
729 self.trUtf8("Read project file"), |
730 self.trUtf8("<p>The project file <b>{0}</b> has invalid contents.</p>")\ |
730 self.trUtf8("<p>The project file <b>{0}</b> has invalid contents.</p>")\ |
731 .format(fn)) |
731 .format(fn)) |
732 eh.showParseMessages() |
732 eh.showParseMessages() |
733 return False |
733 return False |
787 newline = self.getEolString() |
787 newline = self.getEolString() |
788 if fn.lower().endswith("e4pz"): |
788 if fn.lower().endswith("e4pz"): |
789 try: |
789 try: |
790 import gzip |
790 import gzip |
791 except ImportError: |
791 except ImportError: |
792 QMessageBox.critical(None, |
792 E5MessageBox.critical(self.ui, |
793 self.trUtf8("Save project file"), |
793 self.trUtf8("Save project file"), |
794 self.trUtf8("""Compressed project files not supported.""" |
794 self.trUtf8("""Compressed project files not supported.""" |
795 """ The compression library is missing.""")) |
795 """ The compression library is missing.""")) |
796 return False |
796 return False |
797 f = io.StringIO(newline = newline) |
797 f = io.StringIO(newline = newline) |
805 g.write(f.getvalue().encode("utf-8")) |
805 g.write(f.getvalue().encode("utf-8")) |
806 g.close() |
806 g.close() |
807 f.close() |
807 f.close() |
808 |
808 |
809 except IOError: |
809 except IOError: |
810 QMessageBox.critical(None, |
810 E5MessageBox.critical(self.ui, |
811 self.trUtf8("Save project file"), |
811 self.trUtf8("Save project file"), |
812 self.trUtf8("<p>The project file <b>{0}</b> could not be written.</p>")\ |
812 self.trUtf8("<p>The project file <b>{0}</b> could not be written.</p>")\ |
813 .format(fn)) |
813 .format(fn)) |
814 return False |
814 return False |
815 |
815 |
846 buf = io.StringIO(f.read()) |
846 buf = io.StringIO(f.read()) |
847 parser.parse(buf) |
847 parser.parse(buf) |
848 finally: |
848 finally: |
849 f.close() |
849 f.close() |
850 except IOError: |
850 except IOError: |
851 QMessageBox.critical(None, |
851 E5MessageBox.critical(self.ui, |
852 self.trUtf8("Read user project properties"), |
852 self.trUtf8("Read user project properties"), |
853 self.trUtf8("<p>The user specific project properties file <b>{0}</b>" |
853 self.trUtf8("<p>The user specific project properties file <b>{0}</b>" |
854 " could not be read.</p>").format(fn)) |
854 " could not be read.</p>").format(fn)) |
855 return |
855 return |
856 except XMLFatalParseError: |
856 except XMLFatalParseError: |
874 |
874 |
875 UserProjectWriter(f, os.path.splitext(os.path.basename(fn))[0]).writeXML() |
875 UserProjectWriter(f, os.path.splitext(os.path.basename(fn))[0]).writeXML() |
876 |
876 |
877 f.close() |
877 f.close() |
878 except IOError: |
878 except IOError: |
879 QMessageBox.critical(None, |
879 E5MessageBox.critical(self.ui, |
880 self.trUtf8("Save user project properties"), |
880 self.trUtf8("Save user project properties"), |
881 self.trUtf8("<p>The user specific project properties file <b>{0}</b>" |
881 self.trUtf8("<p>The user specific project properties file <b>{0}</b>" |
882 " could not be written.</p>").format(fn)) |
882 " could not be written.</p>").format(fn)) |
883 |
883 |
884 def __readSession(self, quiet = False, indicator = ""): |
884 def __readSession(self, quiet = False, indicator = ""): |
889 If this flag is true, no errors are reported. |
889 If this flag is true, no errors are reported. |
890 @keyparam indicator indicator string (string) |
890 @keyparam indicator indicator string (string) |
891 """ |
891 """ |
892 if self.pfile is None: |
892 if self.pfile is None: |
893 if not quiet: |
893 if not quiet: |
894 QMessageBox.critical(None, |
894 E5MessageBox.critical(self.ui, |
895 self.trUtf8("Read project session"), |
895 self.trUtf8("Read project session"), |
896 self.trUtf8("Please save the project first.")) |
896 self.trUtf8("Please save the project first.")) |
897 return |
897 return |
898 |
898 |
899 fn, ext = os.path.splitext(os.path.basename(self.pfile)) |
899 fn, ext = os.path.splitext(os.path.basename(self.pfile)) |
904 '{0}{1}.e4sz'.format(fn, indicator)) |
904 '{0}{1}.e4sz'.format(fn, indicator)) |
905 try: |
905 try: |
906 import gzip |
906 import gzip |
907 except ImportError: |
907 except ImportError: |
908 if not quiet: |
908 if not quiet: |
909 QMessageBox.critical(None, |
909 E5MessageBox.critical(self.ui, |
910 self.trUtf8("Read project session"), |
910 self.trUtf8("Read project session"), |
911 self.trUtf8("""Compressed project session files not""" |
911 self.trUtf8("""Compressed project session files not""" |
912 """ supported. The compression library is missing.""")) |
912 """ supported. The compression library is missing.""")) |
913 return |
913 return |
914 g = gzip.open(fn, "rb") |
914 g = gzip.open(fn, "rb") |
921 line = f.readline() |
921 line = f.readline() |
922 dtdLine = f.readline() |
922 dtdLine = f.readline() |
923 f.close() |
923 f.close() |
924 except EnvironmentError: |
924 except EnvironmentError: |
925 if not quiet: |
925 if not quiet: |
926 QMessageBox.critical(None, |
926 E5MessageBox.critical(self.ui, |
927 self.trUtf8("Read project session"), |
927 self.trUtf8("Read project session"), |
928 self.trUtf8("<p>The project session <b>{0}</b>" |
928 self.trUtf8("<p>The project session <b>{0}</b>" |
929 " could not be read.</p>")\ |
929 " could not be read.</p>")\ |
930 .format(fn)) |
930 .format(fn)) |
931 return |
931 return |
933 # now read the file |
933 # now read the file |
934 if line.startswith('<?xml'): |
934 if line.startswith('<?xml'): |
935 self.__readXMLSession(fn, dtdLine.startswith("<!DOCTYPE"), quiet) |
935 self.__readXMLSession(fn, dtdLine.startswith("<!DOCTYPE"), quiet) |
936 else: |
936 else: |
937 if not quiet: |
937 if not quiet: |
938 QMessageBox.critical(None, |
938 E5MessageBox.critical(self.ui, |
939 self.trUtf8("Read project session"), |
939 self.trUtf8("Read project session"), |
940 self.trUtf8("<p>The project session <b>{0}</b> has an unsupported" |
940 self.trUtf8("<p>The project session <b>{0}</b> has an unsupported" |
941 " format.</p>").format(fn)) |
941 " format.</p>").format(fn)) |
942 |
942 |
943 def __readXMLSession(self, fn, validating, quiet): |
943 def __readXMLSession(self, fn, validating, quiet): |
979 if fn.lower().endswith("e4sz"): |
979 if fn.lower().endswith("e4sz"): |
980 try: |
980 try: |
981 import gzip |
981 import gzip |
982 except ImportError: |
982 except ImportError: |
983 if not quiet: |
983 if not quiet: |
984 QMessageBox.critical(None, |
984 E5MessageBox.critical(self.ui, |
985 self.trUtf8("Read project session"), |
985 self.trUtf8("Read project session"), |
986 self.trUtf8("<p>The project session <b>{0}</b> could not" |
986 self.trUtf8("<p>The project session <b>{0}</b> could not" |
987 " be read.</p>").format(fn)) |
987 " be read.</p>").format(fn)) |
988 return |
988 return |
989 g = gzip.open(fn, "rb") |
989 g = gzip.open(fn, "rb") |
1000 parser.parse(buf) |
1000 parser.parse(buf) |
1001 finally: |
1001 finally: |
1002 f.close() |
1002 f.close() |
1003 except IOError: |
1003 except IOError: |
1004 if not quiet: |
1004 if not quiet: |
1005 QMessageBox.critical(None, |
1005 E5MessageBox.critical(self.ui, |
1006 self.trUtf8("Read project session"), |
1006 self.trUtf8("Read project session"), |
1007 self.trUtf8("<p>The project session file <b>{0}</b> could not be" |
1007 self.trUtf8("<p>The project session file <b>{0}</b> could not be" |
1008 " read.</p>").format(fn)) |
1008 " read.</p>").format(fn)) |
1009 return |
1009 return |
1010 except XMLFatalParseError: |
1010 except XMLFatalParseError: |
1033 If this flag is true, no errors are reported. |
1033 If this flag is true, no errors are reported. |
1034 @keyparam indicator indicator string (string) |
1034 @keyparam indicator indicator string (string) |
1035 """ |
1035 """ |
1036 if self.pfile is None: |
1036 if self.pfile is None: |
1037 if not quiet: |
1037 if not quiet: |
1038 QMessageBox.critical(None, |
1038 E5MessageBox.critical(self.ui, |
1039 self.trUtf8("Save project session"), |
1039 self.trUtf8("Save project session"), |
1040 self.trUtf8("Please save the project first.")) |
1040 self.trUtf8("Please save the project first.")) |
1041 return |
1041 return |
1042 |
1042 |
1043 fn, ext = os.path.splitext(os.path.basename(self.pfile)) |
1043 fn, ext = os.path.splitext(os.path.basename(self.pfile)) |
1048 '{0}{1}.e4sz'.format(fn, indicator)) |
1048 '{0}{1}.e4sz'.format(fn, indicator)) |
1049 try: |
1049 try: |
1050 import gzip |
1050 import gzip |
1051 except ImportError: |
1051 except ImportError: |
1052 if not quiet: |
1052 if not quiet: |
1053 QMessageBox.critical(None, |
1053 E5MessageBox.critical(self.ui, |
1054 self.trUtf8("Save project session"), |
1054 self.trUtf8("Save project session"), |
1055 self.trUtf8("""Compressed project session files not""" |
1055 self.trUtf8("""Compressed project session files not""" |
1056 """ supported. The compression library is missing.""")) |
1056 """ supported. The compression library is missing.""")) |
1057 return |
1057 return |
1058 f = io.StringIO() |
1058 f = io.StringIO() |
1069 g.close() |
1069 g.close() |
1070 f.close() |
1070 f.close() |
1071 |
1071 |
1072 except IOError: |
1072 except IOError: |
1073 if not quiet: |
1073 if not quiet: |
1074 QMessageBox.critical(None, |
1074 E5MessageBox.critical(self.ui, |
1075 self.trUtf8("Save project session"), |
1075 self.trUtf8("Save project session"), |
1076 self.trUtf8("<p>The project session file <b>{0}</b> could not be" |
1076 self.trUtf8("<p>The project session file <b>{0}</b> could not be" |
1077 " written.</p>").format(fn)) |
1077 " written.</p>").format(fn)) |
1078 |
1078 |
1079 def __deleteSession(self): |
1079 def __deleteSession(self): |
1080 """ |
1080 """ |
1081 Private method to delete the session file. |
1081 Private method to delete the session file. |
1082 """ |
1082 """ |
1083 if self.pfile is None: |
1083 if self.pfile is None: |
1084 if not quiet: |
1084 if not quiet: |
1085 QMessageBox.critical(None, |
1085 E5MessageBox.critical(self.ui, |
1086 self.trUtf8("Delete project session"), |
1086 self.trUtf8("Delete project session"), |
1087 self.trUtf8("Please save the project first.")) |
1087 self.trUtf8("Please save the project first.")) |
1088 return |
1088 return |
1089 |
1089 |
1090 fname, ext = os.path.splitext(os.path.basename(self.pfile)) |
1090 fname, ext = os.path.splitext(os.path.basename(self.pfile)) |
1093 os.path.join(self.getProjectManagementDir(), "{0}.e4s".format(fname))]: |
1093 os.path.join(self.getProjectManagementDir(), "{0}.e4s".format(fname))]: |
1094 if os.path.exists(fn): |
1094 if os.path.exists(fn): |
1095 try: |
1095 try: |
1096 os.remove(fn) |
1096 os.remove(fn) |
1097 except OSError: |
1097 except OSError: |
1098 QMessageBox.critical(None, |
1098 E5MessageBox.critical(self.ui, |
1099 self.trUtf8("Delete project session"), |
1099 self.trUtf8("Delete project session"), |
1100 self.trUtf8("<p>The project session file <b>{0}</b> could not be" |
1100 self.trUtf8("<p>The project session file <b>{0}</b> could not be" |
1101 " deleted.</p>").format(fn)) |
1101 " deleted.</p>").format(fn)) |
1102 |
1102 |
1103 def __readTasks(self): |
1103 def __readTasks(self): |
1104 """ |
1104 """ |
1105 Private method to read in the project tasks file (.e4t) |
1105 Private method to read in the project tasks file (.e4t) |
1106 """ |
1106 """ |
1107 if self.pfile is None: |
1107 if self.pfile is None: |
1108 QMessageBox.critical(None, |
1108 E5MessageBox.critical(self.ui, |
1109 self.trUtf8("Read tasks"), |
1109 self.trUtf8("Read tasks"), |
1110 self.trUtf8("Please save the project first.")) |
1110 self.trUtf8("Please save the project first.")) |
1111 return |
1111 return |
1112 |
1112 |
1113 fn, ext = os.path.splitext(os.path.basename(self.pfile)) |
1113 fn, ext = os.path.splitext(os.path.basename(self.pfile)) |
1118 if not os.path.exists(fn): |
1118 if not os.path.exists(fn): |
1119 return |
1119 return |
1120 try: |
1120 try: |
1121 import gzip |
1121 import gzip |
1122 except ImportError: |
1122 except ImportError: |
1123 QMessageBox.critical(None, |
1123 E5MessageBox.critical(self.ui, |
1124 self.trUtf8("Read tasks"), |
1124 self.trUtf8("Read tasks"), |
1125 self.trUtf8("""Compressed tasks files not supported.""" |
1125 self.trUtf8("""Compressed tasks files not supported.""" |
1126 """ The compression library is missing.""")) |
1126 """ The compression library is missing.""")) |
1127 return |
1127 return |
1128 g = gzip.open(fn, "rb") |
1128 g = gzip.open(fn, "rb") |
1135 f = open(fn, "r", encoding = "utf-8") |
1135 f = open(fn, "r", encoding = "utf-8") |
1136 line = f.readline() |
1136 line = f.readline() |
1137 dtdLine = f.readline() |
1137 dtdLine = f.readline() |
1138 f.close() |
1138 f.close() |
1139 except EnvironmentError: |
1139 except EnvironmentError: |
1140 QMessageBox.critical(None, |
1140 E5MessageBox.critical(self.ui, |
1141 self.trUtf8("Read tasks"), |
1141 self.trUtf8("Read tasks"), |
1142 self.trUtf8("<p>The tasks file <b>{0}</b> could not be read.</p>")\ |
1142 self.trUtf8("<p>The tasks file <b>{0}</b> could not be read.</p>")\ |
1143 .format(fn)) |
1143 .format(fn)) |
1144 return |
1144 return |
1145 |
1145 |
1146 # now read the file |
1146 # now read the file |
1147 if line.startswith('<?xml'): |
1147 if line.startswith('<?xml'): |
1148 self.__readXMLTasks(fn, dtdLine.startswith("<!DOCTYPE")) |
1148 self.__readXMLTasks(fn, dtdLine.startswith("<!DOCTYPE")) |
1149 else: |
1149 else: |
1150 QMessageBox.critical(None, |
1150 E5MessageBox.critical(self.ui, |
1151 self.trUtf8("Read project session"), |
1151 self.trUtf8("Read project session"), |
1152 self.trUtf8("<p>The tasks file <b>{0}</b> has an unsupported" |
1152 self.trUtf8("<p>The tasks file <b>{0}</b> has an unsupported" |
1153 " format.</p>")\ |
1153 " format.</p>")\ |
1154 .format(fn)) |
1154 .format(fn)) |
1155 |
1155 |
1177 try: |
1177 try: |
1178 if fn.lower().endswith("e4tz"): |
1178 if fn.lower().endswith("e4tz"): |
1179 try: |
1179 try: |
1180 import gzip |
1180 import gzip |
1181 except ImportError: |
1181 except ImportError: |
1182 QMessageBox.critical(None, |
1182 E5MessageBox.critical(self.ui, |
1183 self.trUtf8("Read tasks"), |
1183 self.trUtf8("Read tasks"), |
1184 self.trUtf8("""Compressed tasks files not supported.""" |
1184 self.trUtf8("""Compressed tasks files not supported.""" |
1185 """ The compression library is missing.""")) |
1185 """ The compression library is missing.""")) |
1186 return |
1186 return |
1187 g = gzip.open(fn, "rb") |
1187 g = gzip.open(fn, "rb") |
1197 buf = io.StringIO(f.read()) |
1197 buf = io.StringIO(f.read()) |
1198 parser.parse(buf) |
1198 parser.parse(buf) |
1199 finally: |
1199 finally: |
1200 f.close() |
1200 f.close() |
1201 except IOError: |
1201 except IOError: |
1202 QMessageBox.critical(None, |
1202 E5MessageBox.critical(self.ui, |
1203 self.trUtf8("Read tasks"), |
1203 self.trUtf8("Read tasks"), |
1204 self.trUtf8("<p>The tasks file <b>{0}</b> could not be read.</p>")\ |
1204 self.trUtf8("<p>The tasks file <b>{0}</b> could not be read.</p>")\ |
1205 .format(fn)) |
1205 .format(fn)) |
1206 return |
1206 return |
1207 except XMLFatalParseError: |
1207 except XMLFatalParseError: |
1222 if ext.lower() == ".e4pz": |
1222 if ext.lower() == ".e4pz": |
1223 fn = os.path.join(self.getProjectManagementDir(), '{0}.e4tz'.format(fn)) |
1223 fn = os.path.join(self.getProjectManagementDir(), '{0}.e4tz'.format(fn)) |
1224 try: |
1224 try: |
1225 import gzip |
1225 import gzip |
1226 except ImportError: |
1226 except ImportError: |
1227 QMessageBox.critical(None, |
1227 E5MessageBox.critical(self.ui, |
1228 self.trUtf8("Save tasks"), |
1228 self.trUtf8("Save tasks"), |
1229 self.trUtf8("""Compressed tasks files not supported.""" |
1229 self.trUtf8("""Compressed tasks files not supported.""" |
1230 """ The compression library is missing.""")) |
1230 """ The compression library is missing.""")) |
1231 return |
1231 return |
1232 f = io.StringIO() |
1232 f = io.StringIO() |
1241 g.write(f.getvalue().encode("utf-8")) |
1241 g.write(f.getvalue().encode("utf-8")) |
1242 g.close() |
1242 g.close() |
1243 f.close() |
1243 f.close() |
1244 |
1244 |
1245 except IOError: |
1245 except IOError: |
1246 QMessageBox.critical(None, |
1246 E5MessageBox.critical(self.ui, |
1247 self.trUtf8("Save tasks"), |
1247 self.trUtf8("Save tasks"), |
1248 self.trUtf8("<p>The tasks file <b>{0}</b> could not be written.</p>") |
1248 self.trUtf8("<p>The tasks file <b>{0}</b> could not be written.</p>") |
1249 .format(fn)) |
1249 .format(fn)) |
1250 |
1250 |
1251 def __readDebugProperties(self, quiet = False): |
1251 def __readDebugProperties(self, quiet = False): |
1255 @param quiet flag indicating quiet operations. |
1255 @param quiet flag indicating quiet operations. |
1256 If this flag is true, no errors are reported. |
1256 If this flag is true, no errors are reported. |
1257 """ |
1257 """ |
1258 if self.pfile is None: |
1258 if self.pfile is None: |
1259 if not quiet: |
1259 if not quiet: |
1260 QMessageBox.critical(None, |
1260 E5MessageBox.critical(self.ui, |
1261 self.trUtf8("Read debugger properties"), |
1261 self.trUtf8("Read debugger properties"), |
1262 self.trUtf8("Please save the project first.")) |
1262 self.trUtf8("Please save the project first.")) |
1263 return |
1263 return |
1264 |
1264 |
1265 fn, ext = os.path.splitext(os.path.basename(self.pfile)) |
1265 fn, ext = os.path.splitext(os.path.basename(self.pfile)) |
1269 fn = os.path.join(self.getProjectManagementDir(), '{0}.e4dz'.format(fn)) |
1269 fn = os.path.join(self.getProjectManagementDir(), '{0}.e4dz'.format(fn)) |
1270 try: |
1270 try: |
1271 import gzip |
1271 import gzip |
1272 except ImportError: |
1272 except ImportError: |
1273 if not quiet: |
1273 if not quiet: |
1274 QMessageBox.critical(None, |
1274 E5MessageBox.critical(self.ui, |
1275 self.trUtf8("Read debugger properties"), |
1275 self.trUtf8("Read debugger properties"), |
1276 self.trUtf8("""Compressed project session files not""" |
1276 self.trUtf8("""Compressed project session files not""" |
1277 """ supported. The compression library is""" |
1277 """ supported. The compression library is""" |
1278 """ missing.""")) |
1278 """ missing.""")) |
1279 return |
1279 return |
1286 line = f.readline() |
1286 line = f.readline() |
1287 dtdLine = f.readline() |
1287 dtdLine = f.readline() |
1288 f.close() |
1288 f.close() |
1289 except EnvironmentError: |
1289 except EnvironmentError: |
1290 if not quiet: |
1290 if not quiet: |
1291 QMessageBox.critical(None, |
1291 E5MessageBox.critical(self.ui, |
1292 self.trUtf8("Read debugger properties"), |
1292 self.trUtf8("Read debugger properties"), |
1293 self.trUtf8("<p>The project debugger properties file <b>{0}</b> could" |
1293 self.trUtf8("<p>The project debugger properties file <b>{0}</b> could" |
1294 " not be read.</p>").format(fn)) |
1294 " not be read.</p>").format(fn)) |
1295 return |
1295 return |
1296 |
1296 |
1297 # now read the file |
1297 # now read the file |
1298 if line.startswith('<?xml'): |
1298 if line.startswith('<?xml'): |
1299 self.__readXMLDebugProperties(fn, dtdLine.startswith("<!DOCTYPE"), quiet) |
1299 self.__readXMLDebugProperties(fn, dtdLine.startswith("<!DOCTYPE"), quiet) |
1300 else: |
1300 else: |
1301 if not quiet: |
1301 if not quiet: |
1302 QMessageBox.critical(None, |
1302 E5MessageBox.critical(self.ui, |
1303 self.trUtf8("Read debugger properties"), |
1303 self.trUtf8("Read debugger properties"), |
1304 self.trUtf8("<p>The project debugger properties file <b>{0}</b> has" |
1304 self.trUtf8("<p>The project debugger properties file <b>{0}</b> has" |
1305 " an unsupported format.</p>").format(fn)) |
1305 " an unsupported format.</p>").format(fn)) |
1306 |
1306 |
1307 def __readXMLDebugProperties(self, fn, validating, quiet): |
1307 def __readXMLDebugProperties(self, fn, validating, quiet): |
1332 if fn.lower().endswith("e4dz"): |
1332 if fn.lower().endswith("e4dz"): |
1333 try: |
1333 try: |
1334 import gzip |
1334 import gzip |
1335 except ImportError: |
1335 except ImportError: |
1336 if not quiet: |
1336 if not quiet: |
1337 QMessageBox.critical(None, |
1337 E5MessageBox.critical(self.ui, |
1338 self.trUtf8("Read debugger properties"), |
1338 self.trUtf8("Read debugger properties"), |
1339 self.trUtf8("<p>The project debugger properties file" |
1339 self.trUtf8("<p>The project debugger properties file" |
1340 " <b>{0}</b> could not be read.</p>").format(fn)) |
1340 " <b>{0}</b> could not be read.</p>").format(fn)) |
1341 return |
1341 return |
1342 g = gzip.open(fn, "rb") |
1342 g = gzip.open(fn, "rb") |
1357 self.debugPropertiesLoaded = False |
1357 self.debugPropertiesLoaded = False |
1358 finally: |
1358 finally: |
1359 f.close() |
1359 f.close() |
1360 except IOError: |
1360 except IOError: |
1361 if not quiet: |
1361 if not quiet: |
1362 QMessageBox.critical(None, |
1362 E5MessageBox.critical(self.ui, |
1363 self.trUtf8("Read debugger properties"), |
1363 self.trUtf8("Read debugger properties"), |
1364 self.trUtf8("<p>The project debugger properties file <b>{0}</b> could" |
1364 self.trUtf8("<p>The project debugger properties file <b>{0}</b> could" |
1365 " not be read.</p>") |
1365 " not be read.</p>") |
1366 .format(fn)) |
1366 .format(fn)) |
1367 return |
1367 return |
1378 @param quiet flag indicating quiet operations. |
1378 @param quiet flag indicating quiet operations. |
1379 If this flag is true, no errors are reported. |
1379 If this flag is true, no errors are reported. |
1380 """ |
1380 """ |
1381 if self.pfile is None: |
1381 if self.pfile is None: |
1382 if not quiet: |
1382 if not quiet: |
1383 QMessageBox.critical(None, |
1383 E5MessageBox.critical(self.ui, |
1384 self.trUtf8("Save debugger properties"), |
1384 self.trUtf8("Save debugger properties"), |
1385 self.trUtf8("Please save the project first.")) |
1385 self.trUtf8("Please save the project first.")) |
1386 return |
1386 return |
1387 |
1387 |
1388 fn, ext = os.path.splitext(os.path.basename(self.pfile)) |
1388 fn, ext = os.path.splitext(os.path.basename(self.pfile)) |
1392 fn = os.path.join(self.getProjectManagementDir(), '{0}.e4dz'.format(fn)) |
1392 fn = os.path.join(self.getProjectManagementDir(), '{0}.e4dz'.format(fn)) |
1393 try: |
1393 try: |
1394 import gzip |
1394 import gzip |
1395 except ImportError: |
1395 except ImportError: |
1396 if not quiet: |
1396 if not quiet: |
1397 QMessageBox.critical(None, |
1397 E5MessageBox.critical(self.ui, |
1398 self.trUtf8("Save debugger properties"), |
1398 self.trUtf8("Save debugger properties"), |
1399 self.trUtf8("""Compressed project debugger properties files""" |
1399 self.trUtf8("""Compressed project debugger properties files""" |
1400 """ not supported. The compression library is""" |
1400 """ not supported. The compression library is""" |
1401 """ missing.""")) |
1401 """ missing.""")) |
1402 return |
1402 return |
1426 """ |
1426 """ |
1427 Private method to delete the project debugger properties file (.e4d) |
1427 Private method to delete the project debugger properties file (.e4d) |
1428 """ |
1428 """ |
1429 if self.pfile is None: |
1429 if self.pfile is None: |
1430 if not quiet: |
1430 if not quiet: |
1431 QMessageBox.critical(None, |
1431 E5MessageBox.critical(self.ui, |
1432 self.trUtf8("Delete debugger properties"), |
1432 self.trUtf8("Delete debugger properties"), |
1433 self.trUtf8("Please save the project first.")) |
1433 self.trUtf8("Please save the project first.")) |
1434 return |
1434 return |
1435 |
1435 |
1436 fname, ext = os.path.splitext(os.path.basename(self.pfile)) |
1436 fname, ext = os.path.splitext(os.path.basename(self.pfile)) |
1439 os.path.join(self.getProjectManagementDir(), "{0}.e4d".format(fname))]: |
1439 os.path.join(self.getProjectManagementDir(), "{0}.e4d".format(fname))]: |
1440 if os.path.exists(fn): |
1440 if os.path.exists(fn): |
1441 try: |
1441 try: |
1442 os.remove(fn) |
1442 os.remove(fn) |
1443 except OSError: |
1443 except OSError: |
1444 QMessageBox.critical(None, |
1444 E5MessageBox.critical(self.ui, |
1445 self.trUtf8("Delete debugger properties"), |
1445 self.trUtf8("Delete debugger properties"), |
1446 self.trUtf8("<p>The project debugger properties file <b>{0}</b>" |
1446 self.trUtf8("<p>The project debugger properties file <b>{0}</b>" |
1447 " could not be deleted.</p>") |
1447 " could not be deleted.</p>") |
1448 .format(fn)) |
1448 .format(fn)) |
1449 |
1449 |
1523 """ |
1523 """ |
1524 if self.pdata["PROJECTTYPE"][0] in \ |
1524 if self.pdata["PROJECTTYPE"][0] in \ |
1525 ["Qt4", "Qt4C", "E4Plugin", "PySide", "PySideC"] and \ |
1525 ["Qt4", "Qt4C", "E4Plugin", "PySide", "PySideC"] and \ |
1526 (len(self.pdata["TRANSLATIONPATTERN"]) == 0 or \ |
1526 (len(self.pdata["TRANSLATIONPATTERN"]) == 0 or \ |
1527 self.pdata["TRANSLATIONPATTERN"][0] == ''): |
1527 self.pdata["TRANSLATIONPATTERN"][0] == ''): |
1528 QMessageBox.critical(None, |
1528 E5MessageBox.critical(self.ui, |
1529 self.trUtf8("Add Language"), |
1529 self.trUtf8("Add Language"), |
1530 self.trUtf8("You have to specify a translation pattern first.")) |
1530 self.trUtf8("You have to specify a translation pattern first.")) |
1531 return |
1531 return |
1532 |
1532 |
1533 dlg = AddLanguageDialog(self.parent()) |
1533 dlg = AddLanguageDialog(self.parent()) |
1613 try: |
1613 try: |
1614 fn = os.path.join(self.ppath, langFile) |
1614 fn = os.path.join(self.ppath, langFile) |
1615 if os.path.exists(fn): |
1615 if os.path.exists(fn): |
1616 os.remove(fn) |
1616 os.remove(fn) |
1617 except IOError: |
1617 except IOError: |
1618 QMessageBox.critical(None, |
1618 E5MessageBox.critical(self.ui, |
1619 self.trUtf8("Delete translation"), |
1619 self.trUtf8("Delete translation"), |
1620 self.trUtf8("<p>The selected translation file <b>{0}</b> could not be" |
1620 self.trUtf8("<p>The selected translation file <b>{0}</b> could not be" |
1621 " deleted.</p>").format(langFile)) |
1621 " deleted.</p>").format(langFile)) |
1622 return |
1622 return |
1623 |
1623 |
1632 os.path.basename(qmFile))) |
1632 os.path.basename(qmFile))) |
1633 fn = os.path.join(self.ppath, qmFile) |
1633 fn = os.path.join(self.ppath, qmFile) |
1634 if os.path.exists(fn): |
1634 if os.path.exists(fn): |
1635 os.remove(fn) |
1635 os.remove(fn) |
1636 except IOError: |
1636 except IOError: |
1637 QMessageBox.critical(None, |
1637 E5MessageBox.critical(self.ui, |
1638 self.trUtf8("Delete translation"), |
1638 self.trUtf8("Delete translation"), |
1639 self.trUtf8("<p>The selected translation file <b>{0}</b> could not be" |
1639 self.trUtf8("<p>The selected translation file <b>{0}</b> could not be" |
1640 " deleted.</p>").format(qmFile)) |
1640 " deleted.</p>").format(qmFile)) |
1641 return |
1641 return |
1642 |
1642 |
1765 if res != QMessageBox.Yes: |
1765 if res != QMessageBox.Yes: |
1766 return # don't overwrite |
1766 return # don't overwrite |
1767 |
1767 |
1768 shutil.copy(fn, target) |
1768 shutil.copy(fn, target) |
1769 except IOError as why: |
1769 except IOError as why: |
1770 QMessageBox.critical(None, |
1770 E5MessageBox.critical(self.ui, |
1771 self.trUtf8("Add file"), |
1771 self.trUtf8("Add file"), |
1772 self.trUtf8("<p>The selected file <b>{0}</b> could not be" |
1772 self.trUtf8("<p>The selected file <b>{0}</b> could not be" |
1773 " added to <b>{1}</b>.</p><p>Reason: {2}</p>") |
1773 " added to <b>{1}</b>.</p><p>Reason: {2}</p>") |
1774 .format(fn, target, str(why))) |
1774 .format(fn, target, str(why))) |
1775 return |
1775 return |
1776 |
1776 |
1777 self.appendFile(targetfile, isSource or filter == 'source') |
1777 self.appendFile(targetfile, isSource or filter == 'source') |
1778 else: |
1778 else: |
1779 QMessageBox.critical(None, |
1779 E5MessageBox.critical(self.ui, |
1780 self.trUtf8("Add file"), |
1780 self.trUtf8("Add file"), |
1781 self.trUtf8("The target directory must not be empty.")) |
1781 self.trUtf8("The target directory must not be empty.")) |
1782 |
1782 |
1783 def __addSingleDirectory(self, filetype, source, target, quiet = False): |
1783 def __addSingleDirectory(self, filetype, source, target, quiet = False): |
1784 """ |
1784 """ |
1813 |
1813 |
1814 if not Utilities.samepath(target, source) and not os.path.isdir(target): |
1814 if not Utilities.samepath(target, source) and not os.path.isdir(target): |
1815 try: |
1815 try: |
1816 os.makedirs(target) |
1816 os.makedirs(target) |
1817 except IOError as why: |
1817 except IOError as why: |
1818 QMessageBox.critical(self.ui, |
1818 E5MessageBox.critical(self.ui, |
1819 self.trUtf8("Add directory"), |
1819 self.trUtf8("Add directory"), |
1820 self.trUtf8("<p>The target directory <b>{0}</b> could not be" |
1820 self.trUtf8("<p>The target directory <b>{0}</b> could not be" |
1821 " created.</p><p>Reason: {1}</p>") |
1821 " created.</p><p>Reason: {1}</p>") |
1822 .format(target, str(why))) |
1822 .format(target, str(why))) |
1823 return |
1823 return |
1881 startdir = self.ppath |
1881 startdir = self.ppath |
1882 dlg = AddDirectoryDialog(self, filter, self.parent(), startdir = startdir) |
1882 dlg = AddDirectoryDialog(self, filter, self.parent(), startdir = startdir) |
1883 if dlg.exec_() == QDialog.Accepted: |
1883 if dlg.exec_() == QDialog.Accepted: |
1884 filetype, source, target, recursive = dlg.getData() |
1884 filetype, source, target, recursive = dlg.getData() |
1885 if target == '': |
1885 if target == '': |
1886 QMessageBox.critical(None, |
1886 E5MessageBox.critical(self.ui, |
1887 self.trUtf8("Add directory"), |
1887 self.trUtf8("Add directory"), |
1888 self.trUtf8("The target directory must not be empty.")) |
1888 self.trUtf8("The target directory must not be empty.")) |
1889 return |
1889 return |
1890 |
1890 |
1891 if filetype == 'OTHERS': |
1891 if filetype == 'OTHERS': |
1892 self.addToOthers(source) |
1892 self.addToOthers(source) |
1893 return |
1893 return |
1894 |
1894 |
1895 if source == '': |
1895 if source == '': |
1896 QMessageBox.critical(None, |
1896 E5MessageBox.critical(self.ui, |
1897 self.trUtf8("Add directory"), |
1897 self.trUtf8("Add directory"), |
1898 self.trUtf8("The source directory must not be empty.")) |
1898 self.trUtf8("The source directory must not be empty.")) |
1899 return |
1899 return |
1900 |
1900 |
1901 if recursive: |
1901 if recursive: |
2037 return False |
2037 return False |
2038 |
2038 |
2039 try: |
2039 try: |
2040 os.rename(oldfn, newfn) |
2040 os.rename(oldfn, newfn) |
2041 except OSError as msg: |
2041 except OSError as msg: |
2042 QMessageBox.critical(None, |
2042 E5MessageBox.critical(self.ui, |
2043 self.trUtf8("Rename File"), |
2043 self.trUtf8("Rename File"), |
2044 self.trUtf8("""<p>The file <b>{0}</b> could not be renamed.<br />""" |
2044 self.trUtf8("""<p>The file <b>{0}</b> could not be renamed.<br />""" |
2045 """Reason: {1}</p>""").format(oldfn, str(msg))) |
2045 """Reason: {1}</p>""").format(oldfn, str(msg))) |
2046 return False |
2046 return False |
2047 |
2047 |
2207 if ext == '.ui': |
2207 if ext == '.ui': |
2208 fn2 = os.path.join(self.ppath, '{0}.h'.format(fn)) |
2208 fn2 = os.path.join(self.ppath, '{0}.h'.format(fn)) |
2209 if os.path.isfile(fn2): |
2209 if os.path.isfile(fn2): |
2210 os.remove(fn2) |
2210 os.remove(fn2) |
2211 except EnvironmentError: |
2211 except EnvironmentError: |
2212 QMessageBox.critical(None, |
2212 E5MessageBox.critical(self.ui, |
2213 self.trUtf8("Delete file"), |
2213 self.trUtf8("Delete file"), |
2214 self.trUtf8("<p>The selected file <b>{0}</b> could not be deleted.</p>") |
2214 self.trUtf8("<p>The selected file <b>{0}</b> could not be deleted.</p>") |
2215 .format(fn)) |
2215 .format(fn)) |
2216 return False |
2216 return False |
2217 |
2217 |
2230 if not os.path.isabs(dn): |
2230 if not os.path.isabs(dn): |
2231 dn = os.path.join(self.ppath, dn) |
2231 dn = os.path.join(self.ppath, dn) |
2232 try: |
2232 try: |
2233 shutil.rmtree(dn, True) |
2233 shutil.rmtree(dn, True) |
2234 except EnvironmentError: |
2234 except EnvironmentError: |
2235 QMessageBox.critical(None, |
2235 E5MessageBox.critical(self.ui, |
2236 self.trUtf8("Delete directory"), |
2236 self.trUtf8("Delete directory"), |
2237 self.trUtf8("<p>The selected directory <b>{0}</b> could not be" |
2237 self.trUtf8("<p>The selected directory <b>{0}</b> could not be" |
2238 " deleted.</p>").format(fn)) |
2238 " deleted.</p>").format(fn)) |
2239 return False |
2239 return False |
2240 |
2240 |
2309 # create the project directory if it doesn't exist already |
2309 # create the project directory if it doesn't exist already |
2310 if not os.path.isdir(self.ppath): |
2310 if not os.path.isdir(self.ppath): |
2311 try: |
2311 try: |
2312 os.makedirs(self.ppath) |
2312 os.makedirs(self.ppath) |
2313 except EnvironmentError: |
2313 except EnvironmentError: |
2314 QMessageBox.critical(None, |
2314 E5MessageBox.critical(self.ui, |
2315 self.trUtf8("Create project directory"), |
2315 self.trUtf8("Create project directory"), |
2316 self.trUtf8("<p>The project directory <b>{0}</b> could not" |
2316 self.trUtf8("<p>The project directory <b>{0}</b> could not" |
2317 " be created.</p>") |
2317 " be created.</p>") |
2318 .format(self.ppath)) |
2318 .format(self.ppath)) |
2319 self.vcs = self.initVCS() |
2319 self.vcs = self.initVCS() |
3072 success &= vm.saveEditorEd(editor) |
3072 success &= vm.saveEditorEd(editor) |
3073 if reportSyntaxErrors and editor.hasSyntaxErrors(): |
3073 if reportSyntaxErrors and editor.hasSyntaxErrors(): |
3074 filesWithSyntaxErrors += 1 |
3074 filesWithSyntaxErrors += 1 |
3075 |
3075 |
3076 if reportSyntaxErrors and filesWithSyntaxErrors > 0: |
3076 if reportSyntaxErrors and filesWithSyntaxErrors > 0: |
3077 QMessageBox.critical(None, |
3077 E5MessageBox.critical(self.ui, |
3078 self.trUtf8("Syntax errors detected"), |
3078 self.trUtf8("Syntax errors detected"), |
3079 self.trUtf8("""The project contains %n file(s) with syntax errors.""", |
3079 self.trUtf8("""The project contains %n file(s) with syntax errors.""", |
3080 "", filesWithSyntaxErrors) |
3080 "", filesWithSyntaxErrors) |
3081 ) |
3081 ) |
3082 return False |
3082 return False |
4145 vcsExists, msg = vcs.vcsExists() |
4145 vcsExists, msg = vcs.vcsExists() |
4146 if not vcsExists: |
4146 if not vcsExists: |
4147 if override: |
4147 if override: |
4148 # override failed, revert to original |
4148 # override failed, revert to original |
4149 QApplication.restoreOverrideCursor() |
4149 QApplication.restoreOverrideCursor() |
4150 QMessageBox.critical(None, |
4150 E5MessageBox.critical(self.ui, |
4151 self.trUtf8("Version Control System"), |
4151 self.trUtf8("Version Control System"), |
4152 self.trUtf8("<p>The selected VCS <b>{0}</b> could not be found." |
4152 self.trUtf8("<p>The selected VCS <b>{0}</b> could not be found." |
4153 "<br/>Reverting override.</p><p>{1}</p>")\ |
4153 "<br/>Reverting override.</p><p>{1}</p>")\ |
4154 .format(vcsSystem, msg)) |
4154 .format(vcsSystem, msg)) |
4155 self.pudata["VCSOVERRIDE"] = [] |
4155 self.pudata["VCSOVERRIDE"] = [] |
4156 return self.initVCS(nooverride = True) |
4156 return self.initVCS(nooverride = True) |
4157 |
4157 |
4158 QApplication.restoreOverrideCursor() |
4158 QApplication.restoreOverrideCursor() |
4159 QMessageBox.critical(None, |
4159 E5MessageBox.critical(self.ui, |
4160 self.trUtf8("Version Control System"), |
4160 self.trUtf8("Version Control System"), |
4161 self.trUtf8("<p>The selected VCS <b>{0}</b> could not be found.<br/>" |
4161 self.trUtf8("<p>The selected VCS <b>{0}</b> could not be found.<br/>" |
4162 "Disabling version control.</p><p>{1}</p>")\ |
4162 "Disabling version control.</p><p>{1}</p>")\ |
4163 .format(vcsSystem, msg)) |
4163 .format(vcsSystem, msg)) |
4164 vcs = None |
4164 vcs = None |
4246 """ |
4246 """ |
4247 Private slot used to show the code coverage information for the project files. |
4247 Private slot used to show the code coverage information for the project files. |
4248 """ |
4248 """ |
4249 fn = self.getMainScript(True) |
4249 fn = self.getMainScript(True) |
4250 if fn is None: |
4250 if fn is None: |
4251 QMessageBox.critical(self.ui, |
4251 E5MessageBox.critical(self.ui, |
4252 self.trUtf8("Coverage Data"), |
4252 self.trUtf8("Coverage Data"), |
4253 self.trUtf8("There is no main script defined for the" |
4253 self.trUtf8("There is no main script defined for the" |
4254 " current project. Aborting")) |
4254 " current project. Aborting")) |
4255 return |
4255 return |
4256 |
4256 |
4292 """ |
4292 """ |
4293 Private slot used to show the profiling information for the project. |
4293 Private slot used to show the profiling information for the project. |
4294 """ |
4294 """ |
4295 fn = self.getMainScript(True) |
4295 fn = self.getMainScript(True) |
4296 if fn is None: |
4296 if fn is None: |
4297 QMessageBox.critical(self.ui, |
4297 E5MessageBox.critical(self.ui, |
4298 self.trUtf8("Profile Data"), |
4298 self.trUtf8("Profile Data"), |
4299 self.trUtf8("There is no main script defined for the" |
4299 self.trUtf8("There is no main script defined for the" |
4300 " current project. Aborting")) |
4300 " current project. Aborting")) |
4301 return |
4301 return |
4302 |
4302 |
4503 newline = self.getEolString() |
4503 newline = self.getEolString() |
4504 pkglistFile = open(pkglist, "w", encoding = "utf-8", newline = newline) |
4504 pkglistFile = open(pkglist, "w", encoding = "utf-8", newline = newline) |
4505 pkglistFile.write("\n".join(lst)) |
4505 pkglistFile.write("\n".join(lst)) |
4506 pkglistFile.close() |
4506 pkglistFile.close() |
4507 except IOError as why: |
4507 except IOError as why: |
4508 QMessageBox.critical(None, |
4508 E5MessageBox.critical(self.ui, |
4509 self.trUtf8("Create Package List"), |
4509 self.trUtf8("Create Package List"), |
4510 self.trUtf8("""<p>The file <b>PKGLIST</b> could not be created.</p>""" |
4510 self.trUtf8("""<p>The file <b>PKGLIST</b> could not be created.</p>""" |
4511 """<p>Reason: {0}</p>""").format(str(why))) |
4511 """<p>Reason: {0}</p>""").format(str(why))) |
4512 return |
4512 return |
4513 |
4513 |
4520 |
4520 |
4521 @param snapshot flag indicating a snapshot archive (boolean) |
4521 @param snapshot flag indicating a snapshot archive (boolean) |
4522 """ |
4522 """ |
4523 pkglist = os.path.join(self.ppath, "PKGLIST") |
4523 pkglist = os.path.join(self.ppath, "PKGLIST") |
4524 if not os.path.exists(pkglist): |
4524 if not os.path.exists(pkglist): |
4525 QMessageBox.critical(None, |
4525 E5MessageBox.critical(self.ui, |
4526 self.trUtf8("Create Plugin Archive"), |
4526 self.trUtf8("Create Plugin Archive"), |
4527 self.trUtf8("""<p>The file <b>PKGLIST</b> does not exist. """ |
4527 self.trUtf8("""<p>The file <b>PKGLIST</b> does not exist. """ |
4528 """Aborting...</p>""")) |
4528 """Aborting...</p>""")) |
4529 return |
4529 return |
4530 |
4530 |
4531 if len(self.pdata["MAINSCRIPT"]) == 0 or \ |
4531 if len(self.pdata["MAINSCRIPT"]) == 0 or \ |
4532 len(self.pdata["MAINSCRIPT"][0]) == 0: |
4532 len(self.pdata["MAINSCRIPT"][0]) == 0: |
4533 QMessageBox.critical(None, |
4533 E5MessageBox.critical(self.ui, |
4534 self.trUtf8("Create Plugin Archive"), |
4534 self.trUtf8("Create Plugin Archive"), |
4535 self.trUtf8("""The project does not have a main script defined. """ |
4535 self.trUtf8("""The project does not have a main script defined. """ |
4536 """Aborting...""")) |
4536 """Aborting...""")) |
4537 return |
4537 return |
4538 |
4538 |
4540 pkglistFile = open(pkglist, "r", encoding = "utf-8") |
4540 pkglistFile = open(pkglist, "r", encoding = "utf-8") |
4541 names = pkglistFile.read() |
4541 names = pkglistFile.read() |
4542 pkglistFile.close() |
4542 pkglistFile.close() |
4543 names = sorted(names.splitlines()) |
4543 names = sorted(names.splitlines()) |
4544 except IOError as why: |
4544 except IOError as why: |
4545 QMessageBox.critical(None, |
4545 E5MessageBox.critical(self.ui, |
4546 self.trUtf8("Create Plugin Archive"), |
4546 self.trUtf8("Create Plugin Archive"), |
4547 self.trUtf8("""<p>The file <b>PKGLIST</b> could not be read.</p>""" |
4547 self.trUtf8("""<p>The file <b>PKGLIST</b> could not be read.</p>""" |
4548 """<p>Reason: {0}</p>""").format(str(why))) |
4548 """<p>Reason: {0}</p>""").format(str(why))) |
4549 return |
4549 return |
4550 |
4550 |
4554 try: |
4554 try: |
4555 archiveFile = zipfile.ZipFile(archive, "w", zipfile.ZIP_DEFLATED) |
4555 archiveFile = zipfile.ZipFile(archive, "w", zipfile.ZIP_DEFLATED) |
4556 except RuntimeError: |
4556 except RuntimeError: |
4557 archiveFile = zipfile.ZipFile(archive, "w") |
4557 archiveFile = zipfile.ZipFile(archive, "w") |
4558 except IOError as why: |
4558 except IOError as why: |
4559 QMessageBox.critical(None, |
4559 E5MessageBox.critical(self.ui, |
4560 self.trUtf8("Create Plugin Archive"), |
4560 self.trUtf8("Create Plugin Archive"), |
4561 self.trUtf8("""<p>The eric5 plugin archive file <b>{0}</b> could """ |
4561 self.trUtf8("""<p>The eric5 plugin archive file <b>{0}</b> could """ |
4562 """not be created.</p>""" |
4562 """not be created.</p>""" |
4563 """<p>Reason: {1}</p>""").format(archive, str(why))) |
4563 """<p>Reason: {1}</p>""").format(archive, str(why))) |
4564 return |
4564 return |
4574 archiveFile.write(os.path.join(self.ppath, name), name) |
4574 archiveFile.write(os.path.join(self.ppath, name), name) |
4575 if name == self.pdata["MAINSCRIPT"][0]: |
4575 if name == self.pdata["MAINSCRIPT"][0]: |
4576 version = self.__pluginExtractVersion(\ |
4576 version = self.__pluginExtractVersion(\ |
4577 os.path.join(self.ppath, self.pdata["MAINSCRIPT"][0])) |
4577 os.path.join(self.ppath, self.pdata["MAINSCRIPT"][0])) |
4578 except OSError as why: |
4578 except OSError as why: |
4579 QMessageBox.critical(None, |
4579 E5MessageBox.critical(self.ui, |
4580 self.trUtf8("Create Plugin Archive"), |
4580 self.trUtf8("Create Plugin Archive"), |
4581 self.trUtf8("""<p>The file <b>{0}</b> could not be stored """ |
4581 self.trUtf8("""<p>The file <b>{0}</b> could not be stored """ |
4582 """in the archive. Ignoring it.</p>""" |
4582 """in the archive. Ignoring it.</p>""" |
4583 """<p>Reason: {1}</p>""")\ |
4583 """<p>Reason: {1}</p>""")\ |
4584 .format(os.path.join(self.ppath, name), str(why))) |
4584 .format(os.path.join(self.ppath, name), str(why))) |
4629 """ |
4629 """ |
4630 try: |
4630 try: |
4631 sourcelines, encoding = Utilities.readEncodedFile(filename) |
4631 sourcelines, encoding = Utilities.readEncodedFile(filename) |
4632 sourcelines = sourcelines.splitlines(True) |
4632 sourcelines = sourcelines.splitlines(True) |
4633 except (IOError, UnicodeError) as why: |
4633 except (IOError, UnicodeError) as why: |
4634 QMessageBox.critical(None, |
4634 E5MessageBox.critical(self.ui, |
4635 self.trUtf8("Create Plugin Archive"), |
4635 self.trUtf8("Create Plugin Archive"), |
4636 self.trUtf8("""<p>The plugin file <b>{0}</b> could """ |
4636 self.trUtf8("""<p>The plugin file <b>{0}</b> could """ |
4637 """not be read.</p>""" |
4637 """not be read.</p>""" |
4638 """<p>Reason: {1}</p>""").format(archive, str(why))) |
4638 """<p>Reason: {1}</p>""").format(archive, str(why))) |
4639 return b"", "" |
4639 return b"", "" |
4666 version = "0.0.0" |
4666 version = "0.0.0" |
4667 try: |
4667 try: |
4668 sourcelines = Utilities.readEncodedFile(filename)[0] |
4668 sourcelines = Utilities.readEncodedFile(filename)[0] |
4669 sourcelines = sourcelines.splitlines(True) |
4669 sourcelines = sourcelines.splitlines(True) |
4670 except (IOError, UnicodeError) as why: |
4670 except (IOError, UnicodeError) as why: |
4671 QMessageBox.critical(None, |
4671 E5MessageBox.critical(self.ui, |
4672 self.trUtf8("Create Plugin Archive"), |
4672 self.trUtf8("Create Plugin Archive"), |
4673 self.trUtf8("""<p>The plugin file <b>{0}</b> could """ |
4673 self.trUtf8("""<p>The plugin file <b>{0}</b> could """ |
4674 """not be read.</p>""" |
4674 """not be read.</p>""" |
4675 """<p>Reason: {1}</p>""").format(archive, str(why))) |
4675 """<p>Reason: {1}</p>""").format(archive, str(why))) |
4676 return "" |
4676 return "" |