~ubuntu-branches/ubuntu/karmic/eric/karmic

« back to all changes in this revision

Viewing changes to eric/Project/Project.py

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2006-02-28 12:11:32 UTC
  • Revision ID: james.westby@ubuntu.com-20060228121132-8w97p5cd64xj7480
Tags: 3.8.1-1ubuntu1
* Drop Unclear patches (Closes: Malone #32932)
* use python2.4
* Install eric3config to /usr/lib/python2.4/site-packages instead of
  python2.3
* Can open files again (Closes: Malone #29739)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1068
1068
        """
1069
1069
        return self.debugProperties[key]
1070
1070
        
1071
 
    def readTasks(self):
1072
 
        """
1073
 
        Private method to read in the project tasks file (.e3t)
1074
 
        """
1075
 
        if self.pfile is None:
1076
 
            KQMessageBox.critical(None,
1077
 
                self.trUtf8("Read tasks"),
1078
 
                self.trUtf8("Please save the project first."),
1079
 
                self.trUtf8("&Abort"))
1080
 
            return
1081
 
            
1082
 
        fn, ext = os.path.splitext(self.pfile)
1083
 
        
1084
 
        try:
1085
 
            if ext.lower() == ".e3pz":
1086
 
                fn = '%s.e3tz' % fn
1087
 
                if not os.path.exists(fn):
1088
 
                    return
1089
 
                try:
1090
 
                    import gzip
1091
 
                except ImportError:
1092
 
                    KQMessageBox.critical(None,
1093
 
                        self.trUtf8("Read tasks"),
1094
 
                        self.trUtf8("""Compressed tasks files not supported. The compression library is missing."""),
1095
 
                        self.trUtf8("&Abort"),
1096
 
                        None,
1097
 
                        None,
1098
 
                        0, -1)
1099
 
                    return
1100
 
                f = gzip.open(fn, "rb")
1101
 
            else:
1102
 
                fn = '%s.e3t' % fn
1103
 
                if not os.path.exists(fn):
1104
 
                    return
1105
 
                f = open(fn, "rb")
1106
 
            line = f.readline()
1107
 
            dtdLine = f.readline()
1108
 
            f.close()
1109
 
        except:
1110
 
            KQMessageBox.critical(None,
1111
 
                self.trUtf8("Read tasks"),
1112
 
                self.trUtf8("<p>The tasks file <b>%1</b> could not be read.</p>").arg(fn),
1113
 
                self.trUtf8("&Abort"))
1114
 
            return
1115
 
            
1116
 
        # now read the file
1117
 
        if line.startswith('<?xml'):
1118
 
            res = self.readXMLTasks(fn, dtdLine.startswith("<!DOCTYPE"))
1119
 
        else:
1120
 
            KQMessageBox.critical(None,
1121
 
                self.trUtf8("Read project session"),
1122
 
                self.trUtf8("<p>The tasks file <b>%1</b> has an unsupported format.</p>").arg(fn),
1123
 
                self.trUtf8("&Abort"))
1124
 
    
1125
 
    def readXMLTasks(self, fn, validating):
1126
 
        """
1127
 
        Public method to read the project tasks data from an XML file.
1128
 
        
1129
 
        @param fn filename of the project tasks file to be read (string or QString)
1130
 
        @param validating flag indicating a validation of the XML file is
1131
 
            requested (boolean)
1132
 
        """
1133
 
        parser = make_parser(validating)
1134
 
        handler = TasksHandler(1)
1135
 
        er = XMLEntityResolver()
1136
 
        eh = XMLErrorHandler()
1137
 
        
1138
 
        parser.setContentHandler(handler)
1139
 
        parser.setEntityResolver(er)
1140
 
        parser.setErrorHandler(eh)
1141
 
        
1142
 
        try:
1143
 
            if fn.lower().endswith("e3tz"):
1144
 
                try:
1145
 
                    import gzip
1146
 
                except ImportError:
1147
 
                    KQMessageBox.critical(None,
1148
 
                        self.trUtf8("Read tasks"),
1149
 
                        self.trUtf8("""Compressed tasks files not supported. The compression library is missing."""),
1150
 
                        self.trUtf8("&Abort"))
1151
 
                    return
1152
 
                f = gzip.open(fn, "rb")
1153
 
            else:
1154
 
                f = open(fn, "rb")
1155
 
            try:
1156
 
                parser.parse(f)
1157
 
            finally:
1158
 
                f.close()
1159
 
        except IOError:
1160
 
            KQMessageBox.critical(None,
1161
 
                self.trUtf8("Read tasks"),
1162
 
                self.trUtf8("<p>The tasks file <b>%1</b> could not be read.</p>").arg(fn),
1163
 
                self.trUtf8("&Abort"))
1164
 
        except XMLFatalParseError:
1165
 
            pass
1166
 
            
1167
 
        eh.showParseMessages()
1168
 
        
1169
 
    def writeTasks(self):
1170
 
        """
1171
 
        Public method to write the tasks data to an XML file (.e3t).
1172
 
        """
1173
 
        if self.pfile is None:
1174
 
            return
1175
 
            
1176
 
        fn, ext = os.path.splitext(self.pfile)
1177
 
        
1178
 
        try:
1179
 
            if ext.lower() == ".e3pz":
1180
 
                fn = '%s.e3tz' % fn
1181
 
                try:
1182
 
                    import gzip
1183
 
                except ImportError:
1184
 
                    KQMessageBox.critical(None,
1185
 
                        self.trUtf8("Save tasks"),
1186
 
                        self.trUtf8("""Compressed tasks files not supported. The compression library is missing."""),
1187
 
                        self.trUtf8("&Abort"),
1188
 
                        None,
1189
 
                        None,
1190
 
                        0, -1)
1191
 
                    return
1192
 
                f = gzip.open(fn, "wb")
1193
 
            else:
1194
 
                fn = '%s.e3t' % fn
1195
 
                f = open(fn, "wb")
1196
 
            
1197
 
            TasksWriter(f, 1, os.path.splitext(os.path.basename(fn))[0]).writeXML()
1198
 
            
1199
 
            f.close()
1200
 
            
1201
 
        except IOError:
1202
 
            KQMessageBox.critical(None,
1203
 
                self.trUtf8("Save tasks"),
1204
 
                self.trUtf8("<p>The tasks file <b>%1</b> could not be written.</p>")
1205
 
                    .arg(fn),
1206
 
                self.trUtf8("&Abort"))
1207
 
        
1208
1071
    def setDbgInfo(self, argv, wd, env, excReporting, excList, tracePython=None,
1209
1072
                   covexcPattern=None):
1210
1073
        """
1819
1682
        else:
1820
1683
            return 0
1821
1684
        
1822
 
    def deleteDirectory(self, dn):
1823
 
        """
1824
 
        Public slot to delete a directory from the project directory.
1825
 
        
1826
 
        @param dn directory name to be removed from the project
1827
 
        @return flag indicating success
1828
 
        """
1829
 
        dn = unicode(dn)
1830
 
        if not os.path.isabs(dn):
1831
 
            dn = os.path.join(self.ppath, dn)
1832
 
        try:
1833
 
            shutil.rmtree(dn, 1)
1834
 
        except:
1835
 
            KQMessageBox.critical(None,
1836
 
                self.trUtf8("Delete directory"),
1837
 
                self.trUtf8("<p>The selected directory <b>%1</b> could not be deleted.</p>")
1838
 
                    .arg(fn),
1839
 
                self.trUtf8("&OK"))
1840
 
            return 0
1841
 
        
1842
 
        self.removeDirectory(dn)
1843
 
        return 1
1844
 
    
1845
1685
    def newProject(self):
1846
1686
        """
1847
1687
        Public slot to built a new project.
2267
2107
        # now save the tasks
2268
2108
        self.writeTasks()
2269
2109
        
2270
 
        self.sourceExtensions = {\
2271
 
            "Python" : ['.py', '.ptl'],
2272
 
            "Ruby"   : ['.rb'],
2273
 
            "Mixed"  : ['.py', '.ptl', '.rb']
2274
 
        }
2275
 
        
2276
 
        self.sourceFilters = {\
2277
 
            "Python" : self.trUtf8(\
2278
 
                        "Python Files (*.py);;"
2279
 
                        "Quixote PTL Files (*.ptl);;"),
2280
 
            "Ruby"   : self.trUtf8("Ruby Files (*.rb);;"),
2281
 
            "Mixed"  : self.trUtf8(\
2282
 
                        "Python Files (*.py);;"
2283
 
                        "Quixote PTL Files (*.ptl);;"
2284
 
                        "Ruby Files (*.rb);;")
2285
 
        }
2286
 
    
2287
 
        self.uiTypes = [\
2288
 
            ["Qt",      self.trUtf8("Qt")],
2289
 
            ["Kde",     self.trUtf8("KDE")],
2290
 
            ["Console", self.trUtf8("Console")],
2291
 
            ["Other",   self.trUtf8("Other")],
2292
 
        ]
2293
 
    
2294
2110
        self.init()
2295
2111
        self.closeAct.setEnabled(0)
2296
2112
        self.saveasAct.setEnabled(0)
3277
3093
            self.codeCyclopsAct.setEnabled(0)
3278
3094
            self.removeCyclopsAct.setEnabled(0)
3279
3095
        
3280
 
    def svnExtendedDiff(self):
3281
 
        """
3282
 
        Private slot used to perform a svn diff with the selection of revisions.
3283
 
        """
3284
 
        self.vcs.svnExtendedDiff(self.ppath)
3285
 
    
3286
3096
    #########################################################################
3287
3097
    ## Below is the interface to the diagrams
3288
3098
    #########################################################################