14 import shutil |
14 import shutil |
15 import glob |
15 import glob |
16 import fnmatch |
16 import fnmatch |
17 import copy |
17 import copy |
18 import zipfile |
18 import zipfile |
19 import cStringIO |
19 import io |
20 |
20 |
21 from PyQt4.QtCore import * |
21 from PyQt4.QtCore import * |
22 from PyQt4.QtGui import * |
22 from PyQt4.QtGui import * |
23 |
23 |
24 from E4Gui.E4Application import e4App |
24 from E4Gui.E4Application import e4App |
25 |
25 |
26 from Globals import recentNameProject |
26 from Globals import recentNameProject |
27 |
27 |
28 from ProjectBrowserModel import ProjectBrowserModel |
28 from .ProjectBrowserModel import ProjectBrowserModel |
29 |
29 |
30 from AddLanguageDialog import AddLanguageDialog |
30 from .AddLanguageDialog import AddLanguageDialog |
31 from AddFileDialog import AddFileDialog |
31 from .AddFileDialog import AddFileDialog |
32 from AddDirectoryDialog import AddDirectoryDialog |
32 from .AddDirectoryDialog import AddDirectoryDialog |
33 from PropertiesDialog import PropertiesDialog |
33 from .PropertiesDialog import PropertiesDialog |
34 from AddFoundFilesDialog import AddFoundFilesDialog |
34 from .AddFoundFilesDialog import AddFoundFilesDialog |
35 from DebuggerPropertiesDialog import DebuggerPropertiesDialog |
35 from .DebuggerPropertiesDialog import DebuggerPropertiesDialog |
36 from FiletypeAssociationDialog import FiletypeAssociationDialog |
36 from .FiletypeAssociationDialog import FiletypeAssociationDialog |
37 from LexerAssociationDialog import LexerAssociationDialog |
37 from .LexerAssociationDialog import LexerAssociationDialog |
38 from UserPropertiesDialog import UserPropertiesDialog |
38 from .UserPropertiesDialog import UserPropertiesDialog |
39 |
39 |
40 from E4XML.XMLUtilities import make_parser |
40 from E4XML.XMLUtilities import make_parser |
41 from E4XML.XMLErrorHandler import XMLErrorHandler, XMLFatalParseError |
41 from E4XML.XMLErrorHandler import XMLErrorHandler, XMLFatalParseError |
42 from E4XML.XMLEntityResolver import XMLEntityResolver |
42 from E4XML.XMLEntityResolver import XMLEntityResolver |
43 |
43 |
420 if "*.qm" not in self.pdata["FILETYPES"]: |
420 if "*.qm" not in self.pdata["FILETYPES"]: |
421 self.pdata["FILETYPES"]["*.qm"] = "TRANSLATIONS" |
421 self.pdata["FILETYPES"]["*.qm"] = "TRANSLATIONS" |
422 try: |
422 try: |
423 if self.__fileTypeCallbacks[self.pdata["PROJECTTYPE"][0]] is not None: |
423 if self.__fileTypeCallbacks[self.pdata["PROJECTTYPE"][0]] is not None: |
424 ftypes = self.__fileTypeCallbacks[self.pdata["PROJECTTYPE"][0]]() |
424 ftypes = self.__fileTypeCallbacks[self.pdata["PROJECTTYPE"][0]]() |
425 for pattern, ftype in ftypes.items(): |
425 for pattern, ftype in list(ftypes.items()): |
426 if pattern not in self.pdata["FILETYPES"]: |
426 if pattern not in self.pdata["FILETYPES"]: |
427 self.pdata["FILETYPES"][pattern] = ftype |
427 self.pdata["FILETYPES"][pattern] = ftype |
428 self.setDirty(True) |
428 self.setDirty(True) |
429 except KeyError: |
429 except KeyError: |
430 pass |
430 pass |
554 QMessageBox.critical(None, |
554 QMessageBox.critical(None, |
555 self.trUtf8("Read project file"), |
555 self.trUtf8("Read project file"), |
556 self.trUtf8("""Compressed project files not supported.""" |
556 self.trUtf8("""Compressed project files not supported.""" |
557 """ The compression library is missing.""")) |
557 """ The compression library is missing.""")) |
558 return False |
558 return False |
559 f = gzip.open(fn, "rb") |
559 f = gzip.open(fn, "r") |
560 else: |
560 else: |
561 f = open(fn, "rb") |
561 f = open(fn, "r") |
562 line = f.readline() |
562 line = f.readline() |
563 dtdLine = f.readline() |
563 dtdLine = f.readline() |
564 f.close() |
564 f.close() |
565 except EnvironmentError: |
565 except EnvironmentError: |
566 QApplication.restoreOverrideCursor() |
566 QApplication.restoreOverrideCursor() |
662 QMessageBox.critical(None, |
662 QMessageBox.critical(None, |
663 self.trUtf8("Read project file"), |
663 self.trUtf8("Read project file"), |
664 self.trUtf8("""Compressed project files not supported.""" |
664 self.trUtf8("""Compressed project files not supported.""" |
665 """ The compression library is missing.""")) |
665 """ The compression library is missing.""")) |
666 return False |
666 return False |
667 f = gzip.open(fn, "rb") |
667 f = gzip.open(fn, "r") |
668 else: |
668 else: |
669 f = open(fn, "rb") |
669 f = open(fn, "r") |
670 try: |
670 try: |
671 try: |
671 try: |
672 parser.parse(f) |
672 parser.parse(f) |
673 except UnicodeEncodeError: |
673 except UnicodeEncodeError: |
674 f.seek(0) |
674 f.seek(0) |
675 buf = cStringIO.StringIO(f.read()) |
675 buf = io.StringIO(f.read()) |
676 parser.parse(buf) |
676 parser.parse(buf) |
677 finally: |
677 finally: |
678 f.close() |
678 f.close() |
679 except IOError: |
679 except IOError: |
680 QApplication.restoreOverrideCursor() |
680 QApplication.restoreOverrideCursor() |
744 QMessageBox.critical(None, |
744 QMessageBox.critical(None, |
745 self.trUtf8("Save project file"), |
745 self.trUtf8("Save project file"), |
746 self.trUtf8("""Compressed project files not supported.""" |
746 self.trUtf8("""Compressed project files not supported.""" |
747 """ The compression library is missing.""")) |
747 """ The compression library is missing.""")) |
748 return False |
748 return False |
749 f = gzip.open(fn, "wb") |
749 f = gzip.open(fn, "w") |
750 else: |
750 else: |
751 f = open(fn, "wb") |
751 f = open(fn, "w") |
752 |
752 |
753 ProjectWriter(f, os.path.splitext(os.path.basename(fn))[0]).writeXML() |
753 ProjectWriter(f, os.path.splitext(os.path.basename(fn))[0]).writeXML() |
754 |
754 |
755 f.close() |
755 f.close() |
756 |
756 |
773 fn, ext = os.path.splitext(os.path.basename(self.pfile)) |
773 fn, ext = os.path.splitext(os.path.basename(self.pfile)) |
774 |
774 |
775 fn = os.path.join(self.getProjectManagementDir(), '%s.e4q' % fn) |
775 fn = os.path.join(self.getProjectManagementDir(), '%s.e4q' % fn) |
776 if os.path.exists(fn): |
776 if os.path.exists(fn): |
777 try: |
777 try: |
778 f = open(fn, "rb") |
778 f = open(fn, "r") |
779 |
779 |
780 parser = make_parser(True) |
780 parser = make_parser(True) |
781 handler = UserProjectHandler(self) |
781 handler = UserProjectHandler(self) |
782 er = XMLEntityResolver() |
782 er = XMLEntityResolver() |
783 eh = XMLErrorHandler() |
783 eh = XMLErrorHandler() |
862 QMessageBox.critical(None, |
862 QMessageBox.critical(None, |
863 self.trUtf8("Read project session"), |
863 self.trUtf8("Read project session"), |
864 self.trUtf8("""Compressed project session files not""" |
864 self.trUtf8("""Compressed project session files not""" |
865 """ supported. The compression library is missing.""")) |
865 """ supported. The compression library is missing.""")) |
866 return |
866 return |
867 f = gzip.open(fn, "rb") |
867 f = gzip.open(fn, "r") |
868 else: |
868 else: |
869 if ext.lower() == ".e3p": |
869 if ext.lower() == ".e3p": |
870 fn = os.path.join(self.ppath, '%s.e3s' % fn) |
870 fn = os.path.join(self.ppath, '%s.e3s' % fn) |
871 else: |
871 else: |
872 fn = os.path.join(self.getProjectManagementDir(), |
872 fn = os.path.join(self.getProjectManagementDir(), |
873 '%s%s.e4s' % (fn, indicator)) |
873 '%s%s.e4s' % (fn, indicator)) |
874 f = open(fn, "rb") |
874 f = open(fn, "r") |
875 line = f.readline() |
875 line = f.readline() |
876 dtdLine = f.readline() |
876 dtdLine = f.readline() |
877 f.close() |
877 f.close() |
878 except EnvironmentError: |
878 except EnvironmentError: |
879 if not quiet: |
879 if not quiet: |
938 QMessageBox.critical(None, |
938 QMessageBox.critical(None, |
939 self.trUtf8("Read project session"), |
939 self.trUtf8("Read project session"), |
940 self.trUtf8("<p>The project session <b>{0}</b> could not" |
940 self.trUtf8("<p>The project session <b>{0}</b> could not" |
941 " be read.</p>").format(fn)) |
941 " be read.</p>").format(fn)) |
942 return |
942 return |
943 f = gzip.open(fn, "rb") |
943 f = gzip.open(fn, "r") |
944 else: |
944 else: |
945 f = open(fn, "rb") |
945 f = open(fn, "r") |
946 try: |
946 try: |
947 try: |
947 try: |
948 parser.parse(f) |
948 parser.parse(f) |
949 except UnicodeEncodeError: |
949 except UnicodeEncodeError: |
950 f.seek(0) |
950 f.seek(0) |
951 buf = cStringIO.StringIO(f.read()) |
951 buf = io.StringIO(f.read()) |
952 parser.parse(buf) |
952 parser.parse(buf) |
953 finally: |
953 finally: |
954 f.close() |
954 f.close() |
955 except IOError: |
955 except IOError: |
956 if not quiet: |
956 if not quiet: |
1007 QMessageBox.critical(None, |
1007 QMessageBox.critical(None, |
1008 self.trUtf8("Save project session"), |
1008 self.trUtf8("Save project session"), |
1009 self.trUtf8("""Compressed project session files not""" |
1009 self.trUtf8("""Compressed project session files not""" |
1010 """ supported. The compression library is missing.""")) |
1010 """ supported. The compression library is missing.""")) |
1011 return |
1011 return |
1012 f = gzip.open(fn, "wb") |
1012 f = gzip.open(fn, "w") |
1013 else: |
1013 else: |
1014 fn = os.path.join(self.getProjectManagementDir(), |
1014 fn = os.path.join(self.getProjectManagementDir(), |
1015 '%s%s.e4s' % (fn, indicator)) |
1015 '%s%s.e4s' % (fn, indicator)) |
1016 f = open(fn, "wb") |
1016 f = open(fn, "w") |
1017 |
1017 |
1018 SessionWriter(f, os.path.splitext(os.path.basename(fn))[0]).writeXML() |
1018 SessionWriter(f, os.path.splitext(os.path.basename(fn))[0]).writeXML() |
1019 |
1019 |
1020 f.close() |
1020 f.close() |
1021 |
1021 |
1078 QMessageBox.critical(None, |
1078 QMessageBox.critical(None, |
1079 self.trUtf8("Read tasks"), |
1079 self.trUtf8("Read tasks"), |
1080 self.trUtf8("""Compressed tasks files not supported.""" |
1080 self.trUtf8("""Compressed tasks files not supported.""" |
1081 """ The compression library is missing.""")) |
1081 """ The compression library is missing.""")) |
1082 return |
1082 return |
1083 f = gzip.open(fn, "rb") |
1083 f = gzip.open(fn, "r") |
1084 else: |
1084 else: |
1085 if ext.lower() == ".e3p": |
1085 if ext.lower() == ".e3p": |
1086 fn = os.path.join(self.ppath, '%s.e3t' % fn) |
1086 fn = os.path.join(self.ppath, '%s.e3t' % fn) |
1087 else: |
1087 else: |
1088 fn = os.path.join(self.getProjectManagementDir(), '%s.e4t' % fn) |
1088 fn = os.path.join(self.getProjectManagementDir(), '%s.e4t' % fn) |
1089 if not os.path.exists(fn): |
1089 if not os.path.exists(fn): |
1090 return |
1090 return |
1091 f = open(fn, "rb") |
1091 f = open(fn, "r") |
1092 line = f.readline() |
1092 line = f.readline() |
1093 dtdLine = f.readline() |
1093 dtdLine = f.readline() |
1094 f.close() |
1094 f.close() |
1095 except EnvironmentError: |
1095 except EnvironmentError: |
1096 QMessageBox.critical(None, |
1096 QMessageBox.critical(None, |
1138 QMessageBox.critical(None, |
1138 QMessageBox.critical(None, |
1139 self.trUtf8("Read tasks"), |
1139 self.trUtf8("Read tasks"), |
1140 self.trUtf8("""Compressed tasks files not supported.""" |
1140 self.trUtf8("""Compressed tasks files not supported.""" |
1141 """ The compression library is missing.""")) |
1141 """ The compression library is missing.""")) |
1142 return |
1142 return |
1143 f = gzip.open(fn, "rb") |
1143 f = gzip.open(fn, "r") |
1144 else: |
1144 else: |
1145 f = open(fn, "rb") |
1145 f = open(fn, "r") |
1146 try: |
1146 try: |
1147 try: |
1147 try: |
1148 parser.parse(f) |
1148 parser.parse(f) |
1149 except UnicodeEncodeError: |
1149 except UnicodeEncodeError: |
1150 f.seek(0) |
1150 f.seek(0) |
1151 buf = cStringIO.StringIO(f.read()) |
1151 buf = io.StringIO(f.read()) |
1152 parser.parse(buf) |
1152 parser.parse(buf) |
1153 finally: |
1153 finally: |
1154 f.close() |
1154 f.close() |
1155 except IOError: |
1155 except IOError: |
1156 QMessageBox.critical(None, |
1156 QMessageBox.critical(None, |
1181 QMessageBox.critical(None, |
1181 QMessageBox.critical(None, |
1182 self.trUtf8("Save tasks"), |
1182 self.trUtf8("Save tasks"), |
1183 self.trUtf8("""Compressed tasks files not supported.""" |
1183 self.trUtf8("""Compressed tasks files not supported.""" |
1184 """ The compression library is missing.""")) |
1184 """ The compression library is missing.""")) |
1185 return |
1185 return |
1186 f = gzip.open(fn, "wb") |
1186 f = gzip.open(fn, "w") |
1187 else: |
1187 else: |
1188 fn = os.path.join(self.getProjectManagementDir(), '%s.e4t' % fn) |
1188 fn = os.path.join(self.getProjectManagementDir(), '%s.e4t' % fn) |
1189 f = open(fn, "wb") |
1189 f = open(fn, "w") |
1190 |
1190 |
1191 TasksWriter(f, True, os.path.splitext(os.path.basename(fn))[0]).writeXML() |
1191 TasksWriter(f, True, os.path.splitext(os.path.basename(fn))[0]).writeXML() |
1192 |
1192 |
1193 f.close() |
1193 f.close() |
1194 |
1194 |
1228 self.trUtf8("Read debugger properties"), |
1228 self.trUtf8("Read debugger properties"), |
1229 self.trUtf8("""Compressed project session files not""" |
1229 self.trUtf8("""Compressed project session files not""" |
1230 """ supported. The compression library is""" |
1230 """ supported. The compression library is""" |
1231 """ missing.""")) |
1231 """ missing.""")) |
1232 return |
1232 return |
1233 f = gzip.open(fn, "rb") |
1233 f = gzip.open(fn, "r") |
1234 else: |
1234 else: |
1235 if ext.lower() == ".e3p": |
1235 if ext.lower() == ".e3p": |
1236 fn = os.path.join(self.ppath, '%s.e3d' % fn) |
1236 fn = os.path.join(self.ppath, '%s.e3d' % fn) |
1237 else: |
1237 else: |
1238 fn = os.path.join(self.getProjectManagementDir(), '%s.e4d' % fn) |
1238 fn = os.path.join(self.getProjectManagementDir(), '%s.e4d' % fn) |
1239 f = open(fn, "rb") |
1239 f = open(fn, "r") |
1240 line = f.readline() |
1240 line = f.readline() |
1241 dtdLine = f.readline() |
1241 dtdLine = f.readline() |
1242 f.close() |
1242 f.close() |
1243 except EnvironmentError: |
1243 except EnvironmentError: |
1244 if not quiet: |
1244 if not quiet: |
1291 QMessageBox.critical(None, |
1291 QMessageBox.critical(None, |
1292 self.trUtf8("Read debugger properties"), |
1292 self.trUtf8("Read debugger properties"), |
1293 self.trUtf8("<p>The project debugger properties file" |
1293 self.trUtf8("<p>The project debugger properties file" |
1294 " <b>{0}</b> could not be read.</p>").format(fn)) |
1294 " <b>{0}</b> could not be read.</p>").format(fn)) |
1295 return |
1295 return |
1296 f = gzip.open(fn, "rb") |
1296 f = gzip.open(fn, "r") |
1297 else: |
1297 else: |
1298 f = open(fn, "rb") |
1298 f = open(fn, "r") |
1299 try: |
1299 try: |
1300 try: |
1300 try: |
1301 parser.parse(f) |
1301 parser.parse(f) |
1302 except UnicodeEncodeError: |
1302 except UnicodeEncodeError: |
1303 f.seek(0) |
1303 f.seek(0) |
1304 buf = cStringIO.StringIO(f.read()) |
1304 buf = io.StringIO(f.read()) |
1305 parser.parse(buf) |
1305 parser.parse(buf) |
1306 if self.debugProperties["INTERPRETER"]: |
1306 if self.debugProperties["INTERPRETER"]: |
1307 self.debugPropertiesLoaded = True |
1307 self.debugPropertiesLoaded = True |
1308 else: |
1308 else: |
1309 self.debugPropertiesLoaded = False |
1309 self.debugPropertiesLoaded = False |
1352 self.trUtf8("Save debugger properties"), |
1352 self.trUtf8("Save debugger properties"), |
1353 self.trUtf8("""Compressed project debugger properties files""" |
1353 self.trUtf8("""Compressed project debugger properties files""" |
1354 """ not supported. The compression library is""" |
1354 """ not supported. The compression library is""" |
1355 """ missing.""")) |
1355 """ missing.""")) |
1356 return |
1356 return |
1357 f = gzip.open(fn, "wb") |
1357 f = gzip.open(fn, "w") |
1358 else: |
1358 else: |
1359 fn = os.path.join(self.getProjectManagementDir(), '%s.e4d' % fn) |
1359 fn = os.path.join(self.getProjectManagementDir(), '%s.e4d' % fn) |
1360 f = open(fn, "wb") |
1360 f = open(fn, "w") |
1361 |
1361 |
1362 DebuggerPropertiesWriter(f, os.path.splitext(os.path.basename(fn))[0])\ |
1362 DebuggerPropertiesWriter(f, os.path.splitext(os.path.basename(fn))[0])\ |
1363 .writeXML() |
1363 .writeXML() |
1364 |
1364 |
1365 f.close() |
1365 f.close() |
1715 QMessageBox.No) |
1715 QMessageBox.No) |
1716 if res != QMessageBox.Yes: |
1716 if res != QMessageBox.Yes: |
1717 return # don't overwrite |
1717 return # don't overwrite |
1718 |
1718 |
1719 shutil.copy(fn, target) |
1719 shutil.copy(fn, target) |
1720 except IOError, why: |
1720 except IOError as why: |
1721 QMessageBox.critical(None, |
1721 QMessageBox.critical(None, |
1722 self.trUtf8("Add file"), |
1722 self.trUtf8("Add file"), |
1723 self.trUtf8("<p>The selected file <b>{0}</b> could not be" |
1723 self.trUtf8("<p>The selected file <b>{0}</b> could not be" |
1724 " added to <b>{1}</b>.</p>") |
1724 " added to <b>{1}</b>.</p>") |
1725 .format(fn, target), |
1725 .format(fn, target), |
1745 @param quiet flag indicating quiet operations (boolean) |
1745 @param quiet flag indicating quiet operations (boolean) |
1746 """ |
1746 """ |
1747 # get all relevant filename patterns |
1747 # get all relevant filename patterns |
1748 patterns = [] |
1748 patterns = [] |
1749 ignorePatterns = [] |
1749 ignorePatterns = [] |
1750 for pattern, patterntype in self.pdata["FILETYPES"].items(): |
1750 for pattern, patterntype in list(self.pdata["FILETYPES"].items()): |
1751 if patterntype == filetype: |
1751 if patterntype == filetype: |
1752 patterns.append(pattern) |
1752 patterns.append(pattern) |
1753 elif patterntype == "__IGNORE__": |
1753 elif patterntype == "__IGNORE__": |
1754 ignorePatterns.append(pattern) |
1754 ignorePatterns.append(pattern) |
1755 |
1755 |
1767 return |
1767 return |
1768 |
1768 |
1769 if not Utilities.samepath(target, source) and not os.path.isdir(target): |
1769 if not Utilities.samepath(target, source) and not os.path.isdir(target): |
1770 try: |
1770 try: |
1771 os.makedirs(target) |
1771 os.makedirs(target) |
1772 except IOError, why: |
1772 except IOError as why: |
1773 QMessageBox.critical(None, |
1773 QMessageBox.critical(None, |
1774 self.trUtf8("Add directory"), |
1774 self.trUtf8("Add directory"), |
1775 self.trUtf8("<p>The target directory <b>{0}</b> could not be" |
1775 self.trUtf8("<p>The target directory <b>{0}</b> could not be" |
1776 " created.</p>") |
1776 " created.</p>") |
1777 .format(target), |
1777 .format(target), |
1996 if canceled != QMessageBox.Yes: |
1996 if canceled != QMessageBox.Yes: |
1997 return False |
1997 return False |
1998 |
1998 |
1999 try: |
1999 try: |
2000 os.rename(oldfn, newfn) |
2000 os.rename(oldfn, newfn) |
2001 except OSError, msg: |
2001 except OSError as msg: |
2002 QMessageBox.critical(None, |
2002 QMessageBox.critical(None, |
2003 self.trUtf8("Rename File"), |
2003 self.trUtf8("Rename File"), |
2004 self.trUtf8("""<p>The file <b>{0}</b> could not be renamed.<br />""" |
2004 self.trUtf8("""<p>The file <b>{0}</b> could not be renamed.<br />""" |
2005 """Reason: {1}</p>""").format(oldfn, unicode(msg))) |
2005 """Reason: {1}</p>""").format(oldfn, str(msg))) |
2006 return False |
2006 return False |
2007 |
2007 |
2008 if fn in self.pdata["SOURCES"] or \ |
2008 if fn in self.pdata["SOURCES"] or \ |
2009 fn in self.pdata["FORMS"] or \ |
2009 fn in self.pdata["FORMS"] or \ |
2010 fn in self.pdata["TRANSLATIONS"] or \ |
2010 fn in self.pdata["TRANSLATIONS"] or \ |
2326 self.saveProject() |
2326 self.saveProject() |
2327 |
2327 |
2328 # check, if the existing project directory is already under |
2328 # check, if the existing project directory is already under |
2329 # VCS control |
2329 # VCS control |
2330 pluginManager = e4App().getObject("PluginManager") |
2330 pluginManager = e4App().getObject("PluginManager") |
2331 for indicator, vcsData in pluginManager.getVcsSystemIndicators().items(): |
2331 for indicator, vcsData in list(pluginManager.getVcsSystemIndicators().items()): |
2332 if os.path.exists(os.path.join(self.ppath, indicator)): |
2332 if os.path.exists(os.path.join(self.ppath, indicator)): |
2333 if len(vcsData) > 1: |
2333 if len(vcsData) > 1: |
2334 vcsList = [] |
2334 vcsList = [] |
2335 for vcsSystemStr, vcsSystemDisplay in vcsData: |
2335 for vcsSystemStr, vcsSystemDisplay in vcsData: |
2336 vcsList.append(vcsSystemDisplay) |
2336 vcsList.append(vcsSystemDisplay) |
2399 self.trUtf8("New Project"), |
2399 self.trUtf8("New Project"), |
2400 self.trUtf8("Select version control system for the project"), |
2400 self.trUtf8("Select version control system for the project"), |
2401 vcsSystemsDisplay, |
2401 vcsSystemsDisplay, |
2402 0, False) |
2402 0, False) |
2403 if ok and vcsSelected != self.trUtf8("None"): |
2403 if ok and vcsSelected != self.trUtf8("None"): |
2404 for vcsSystem, vcsSystemDisplay in vcsSystemsDict.items(): |
2404 for vcsSystem, vcsSystemDisplay in list(vcsSystemsDict.items()): |
2405 if vcsSystemDisplay == vcsSelected: |
2405 if vcsSystemDisplay == vcsSelected: |
2406 break |
2406 break |
2407 else: |
2407 else: |
2408 vcsSystem = "None" |
2408 vcsSystem = "None" |
2409 self.pdata["VCS"] = [vcsSystem] |
2409 self.pdata["VCS"] = [vcsSystem] |
2454 """ |
2454 """ |
2455 QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) |
2455 QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) |
2456 QApplication.processEvents() |
2456 QApplication.processEvents() |
2457 |
2457 |
2458 # search the project directory for files with known extensions |
2458 # search the project directory for files with known extensions |
2459 filespecs = self.pdata["FILETYPES"].keys() |
2459 filespecs = list(self.pdata["FILETYPES"].keys()) |
2460 for filespec in filespecs: |
2460 for filespec in filespecs: |
2461 files = Utilities.direntries(self.ppath, True, filespec) |
2461 files = Utilities.direntries(self.ppath, True, filespec) |
2462 for file in files: |
2462 for file in files: |
2463 self.appendFile(file) |
2463 self.appendFile(file) |
2464 |
2464 |
2643 |
2643 |
2644 @param filename filename used to determine the associated lexer language (string) |
2644 @param filename filename used to determine the associated lexer language (string) |
2645 @return the requested lexer language (string) |
2645 @return the requested lexer language (string) |
2646 """ |
2646 """ |
2647 # try user settings first |
2647 # try user settings first |
2648 for pattern, language in self.pdata["LEXERASSOCS"].items(): |
2648 for pattern, language in list(self.pdata["LEXERASSOCS"].items()): |
2649 if fnmatch.fnmatch(filename, pattern): |
2649 if fnmatch.fnmatch(filename, pattern): |
2650 return language |
2650 return language |
2651 |
2651 |
2652 # try project type specific defaults next |
2652 # try project type specific defaults next |
2653 projectType = self.pdata["PROJECTTYPE"][0] |
2653 projectType = self.pdata["PROJECTTYPE"][0] |
2709 self.vcs = self.initVCS() |
2709 self.vcs = self.initVCS() |
2710 if self.vcs is None: |
2710 if self.vcs is None: |
2711 # check, if project is version controlled |
2711 # check, if project is version controlled |
2712 pluginManager = e4App().getObject("PluginManager") |
2712 pluginManager = e4App().getObject("PluginManager") |
2713 for indicator, vcsData in \ |
2713 for indicator, vcsData in \ |
2714 pluginManager.getVcsSystemIndicators().items(): |
2714 list(pluginManager.getVcsSystemIndicators().items()): |
2715 if os.path.exists(os.path.join(self.ppath, indicator)): |
2715 if os.path.exists(os.path.join(self.ppath, indicator)): |
2716 if len(vcsData) > 1: |
2716 if len(vcsData) > 1: |
2717 vcsList = [] |
2717 vcsList = [] |
2718 for vcsSystemStr, vcsSystemDisplay in vcsData: |
2718 for vcsSystemStr, vcsSystemDisplay in vcsData: |
2719 vcsList.append(vcsSystemDisplay) |
2719 vcsList.append(vcsSystemDisplay) |
4384 if "PKGLIST" in lst: |
4384 if "PKGLIST" in lst: |
4385 lst.remove("PKGLIST") |
4385 lst.remove("PKGLIST") |
4386 |
4386 |
4387 # write the file |
4387 # write the file |
4388 try: |
4388 try: |
4389 pkglistFile = open(pkglist, "wb") |
4389 pkglistFile = open(pkglist, "w") |
4390 pkglistFile.write("\n".join(lst)) |
4390 pkglistFile.write("\n".join(lst)) |
4391 pkglistFile.close() |
4391 pkglistFile.close() |
4392 except IOError, why: |
4392 except IOError as why: |
4393 QMessageBox.critical(None, |
4393 QMessageBox.critical(None, |
4394 self.trUtf8("Create Package List"), |
4394 self.trUtf8("Create Package List"), |
4395 self.trUtf8("""<p>The file <b>PKGLIST</b> could not be created.</p>""" |
4395 self.trUtf8("""<p>The file <b>PKGLIST</b> could not be created.</p>""" |
4396 """<p>Reason: {0}</p>""").format(unicode(why)), |
4396 """<p>Reason: {0}</p>""").format(str(why)), |
4397 QMessageBox.StandardButtons(\ |
4397 QMessageBox.StandardButtons(\ |
4398 QMessageBox.Ok)) |
4398 QMessageBox.Ok)) |
4399 return |
4399 return |
4400 |
4400 |
4401 if not "PKGLIST" in self.pdata["OTHERS"]: |
4401 if not "PKGLIST" in self.pdata["OTHERS"]: |
4426 QMessageBox.StandardButtons(\ |
4426 QMessageBox.StandardButtons(\ |
4427 QMessageBox.Ok)) |
4427 QMessageBox.Ok)) |
4428 return |
4428 return |
4429 |
4429 |
4430 try: |
4430 try: |
4431 pkglistFile = open(pkglist, "rb") |
4431 pkglistFile = open(pkglist, "r") |
4432 names = pkglistFile.read() |
4432 names = pkglistFile.read() |
4433 pkglistFile.close() |
4433 pkglistFile.close() |
4434 names = names.splitlines() |
4434 names = sorted(names.splitlines()) |
4435 names.sort() |
4435 except IOError as why: |
4436 except IOError, why: |
|
4437 QMessageBox.critical(None, |
4436 QMessageBox.critical(None, |
4438 self.trUtf8("Create Plugin Archive"), |
4437 self.trUtf8("Create Plugin Archive"), |
4439 self.trUtf8("""<p>The file <b>PKGLIST</b> could not be read.</p>""" |
4438 self.trUtf8("""<p>The file <b>PKGLIST</b> could not be read.</p>""" |
4440 """<p>Reason: {0}</p>""").format(unicode(why)), |
4439 """<p>Reason: {0}</p>""").format(str(why)), |
4441 QMessageBox.StandardButtons(\ |
4440 QMessageBox.StandardButtons(\ |
4442 QMessageBox.Ok)) |
4441 QMessageBox.Ok)) |
4443 return |
4442 return |
4444 |
4443 |
4445 archive = \ |
4444 archive = \ |
4447 try: |
4446 try: |
4448 try: |
4447 try: |
4449 archiveFile = zipfile.ZipFile(archive, "w", zipfile.ZIP_DEFLATED) |
4448 archiveFile = zipfile.ZipFile(archive, "w", zipfile.ZIP_DEFLATED) |
4450 except RuntimeError: |
4449 except RuntimeError: |
4451 archiveFile = zipfile.ZipFile(archive, "w") |
4450 archiveFile = zipfile.ZipFile(archive, "w") |
4452 except IOError, why: |
4451 except IOError as why: |
4453 QMessageBox.critical(None, |
4452 QMessageBox.critical(None, |
4454 self.trUtf8("Create Plugin Archive"), |
4453 self.trUtf8("Create Plugin Archive"), |
4455 self.trUtf8("""<p>The eric4 plugin archive file <b>{0}</b> could """ |
4454 self.trUtf8("""<p>The eric4 plugin archive file <b>{0}</b> could """ |
4456 """not be created.</p>""" |
4455 """not be created.</p>""" |
4457 """<p>Reason: {1}</p>""").format(archive, unicode(why)), |
4456 """<p>Reason: {1}</p>""").format(archive, str(why)), |
4458 QMessageBox.StandardButtons(\ |
4457 QMessageBox.StandardButtons(\ |
4459 QMessageBox.Ok)) |
4458 QMessageBox.Ok)) |
4460 return |
4459 return |
4461 |
4460 |
4462 for name in names: |
4461 for name in names: |
4469 else: |
4468 else: |
4470 archiveFile.write(os.path.join(self.ppath, name), name) |
4469 archiveFile.write(os.path.join(self.ppath, name), name) |
4471 if name == self.pdata["MAINSCRIPT"][0]: |
4470 if name == self.pdata["MAINSCRIPT"][0]: |
4472 version = self.__pluginExtractVersion(\ |
4471 version = self.__pluginExtractVersion(\ |
4473 os.path.join(self.ppath, self.pdata["MAINSCRIPT"][0])) |
4472 os.path.join(self.ppath, self.pdata["MAINSCRIPT"][0])) |
4474 except OSError, why: |
4473 except OSError as why: |
4475 QMessageBox.critical(None, |
4474 QMessageBox.critical(None, |
4476 self.trUtf8("Create Plugin Archive"), |
4475 self.trUtf8("Create Plugin Archive"), |
4477 self.trUtf8("""<p>The file <b>{0}</b> could not be stored """ |
4476 self.trUtf8("""<p>The file <b>{0}</b> could not be stored """ |
4478 """in the archive. Ignoring it.</p>""" |
4477 """in the archive. Ignoring it.</p>""" |
4479 """<p>Reason: {1}</p>""")\ |
4478 """<p>Reason: {1}</p>""")\ |
4480 .format(os.path.join(self.ppath, name), unicode(why)), |
4479 .format(os.path.join(self.ppath, name), str(why)), |
4481 QMessageBox.StandardButtons(\ |
4480 QMessageBox.StandardButtons(\ |
4482 QMessageBox.Ok)) |
4481 QMessageBox.Ok)) |
4483 archiveFile.writestr("VERSION", version) |
4482 archiveFile.writestr("VERSION", version) |
4484 archiveFile.close() |
4483 archiveFile.close() |
4485 |
4484 |
4529 """ |
4528 """ |
4530 try: |
4529 try: |
4531 f = open(filename, "r") |
4530 f = open(filename, "r") |
4532 sourcelines = f.readlines() |
4531 sourcelines = f.readlines() |
4533 f.close() |
4532 f.close() |
4534 except IOError, why: |
4533 except IOError as why: |
4535 QMessageBox.critical(None, |
4534 QMessageBox.critical(None, |
4536 self.trUtf8("Create Plugin Archive"), |
4535 self.trUtf8("Create Plugin Archive"), |
4537 self.trUtf8("""<p>The plugin file <b>{0}</b> could """ |
4536 self.trUtf8("""<p>The plugin file <b>{0}</b> could """ |
4538 """not be read.</p>""" |
4537 """not be read.</p>""" |
4539 """<p>Reason: {1}</p>""").format(archive, unicode(why)), |
4538 """<p>Reason: {1}</p>""").format(archive, str(why)), |
4540 QMessageBox.StandardButtons(\ |
4539 QMessageBox.StandardButtons(\ |
4541 QMessageBox.Ok)) |
4540 QMessageBox.Ok)) |
4542 return "" |
4541 return "" |
4543 |
4542 |
4544 lineno = 0 |
4543 lineno = 0 |
4568 version = "0.0.0" |
4567 version = "0.0.0" |
4569 try: |
4568 try: |
4570 f = open(filename, "r") |
4569 f = open(filename, "r") |
4571 sourcelines = f.readlines() |
4570 sourcelines = f.readlines() |
4572 f.close() |
4571 f.close() |
4573 except IOError, why: |
4572 except IOError as why: |
4574 QMessageBox.critical(None, |
4573 QMessageBox.critical(None, |
4575 self.trUtf8("Create Plugin Archive"), |
4574 self.trUtf8("Create Plugin Archive"), |
4576 self.trUtf8("""<p>The plugin file <b>{0}</b> could """ |
4575 self.trUtf8("""<p>The plugin file <b>{0}</b> could """ |
4577 """not be read.</p>""" |
4576 """not be read.</p>""" |
4578 """<p>Reason: {1}</p>""").format(archive, unicode(why)), |
4577 """<p>Reason: {1}</p>""").format(archive, str(why)), |
4579 QMessageBox.StandardButtons(\ |
4578 QMessageBox.StandardButtons(\ |
4580 QMessageBox.Ok)) |
4579 QMessageBox.Ok)) |
4581 return "" |
4580 return "" |
4582 |
4581 |
4583 lineno = 0 |
4582 lineno = 0 |