diff -r ccf4828e914f -r 0a519a18d691 Project/Project.py --- a/Project/Project.py Mon Apr 22 20:31:17 2013 +0200 +++ b/Project/Project.py Sun Apr 28 10:20:32 2013 +0200 @@ -14,7 +14,6 @@ import fnmatch import copy import zipfile -import re from PyQt4.QtCore import QFile, QFileInfo, pyqtSignal, QCryptographicHash, QIODevice, \ QByteArray, QObject, Qt @@ -392,7 +391,6 @@ self.__dirty = False # dirty flag self.pfile = "" # name of the project file self.ppath = "" # name of the project directory - self.ppathRe = None self.translationsRoot = "" # the translations prefix self.name = "" self.opened = False @@ -650,21 +648,6 @@ self.pdata[index].remove(file) self.setDirty(True) - def __makePpathRe(self): - """ - Private method to generate a regular expression for the project path. - """ - ppathRe = (self.ppath + os.sep)\ - .replace("\\", "@@")\ - .replace("/", "@@")\ - .replace("@@", r"[\\/]") - if ppathRe.endswith(r"[\\/]"): - ppathRe += "*" - if Utilities.isWindowsPlatform(): - self.ppathRe = re.compile(ppathRe, re.IGNORECASE) - else: - self.ppathRe = re.compile(ppathRe) - def __readProject(self, fn): """ Private method to read in a project (.e4p) file. @@ -688,7 +671,6 @@ self.pfile = os.path.abspath(fn) self.ppath = os.path.abspath(os.path.dirname(fn)) - self.__makePpathRe() # insert filename into list of recently opened projects self.__syncRecent() @@ -775,7 +757,6 @@ if res: self.pfile = os.path.abspath(fn) self.ppath = os.path.abspath(os.path.dirname(fn)) - self.__makePpathRe() self.name = os.path.splitext(os.path.basename(fn))[0] self.setDirty(False) @@ -1877,7 +1858,6 @@ if dlg.exec_() == QDialog.Accepted: self.closeProject() dlg.storeData() - self.__makePpathRe() self.pdata["VCS"] = ['None'] self.opened = True if not self.pdata["FILETYPES"]: @@ -2848,10 +2828,14 @@ @param path path to be checked (string) """ - if self.ppath and path == self.ppath: - return True - elif self.ppathRe: - return self.ppathRe.match(path) is not None + if self.ppath: + if path == self.ppath: + return True + elif Utilities.normcasepath(Utilities.toNativeSeparators(path)).startswith( + Utilities.normcasepath(Utilities.toNativeSeparators(self.ppath))): + return True + else: + return False else: return False @@ -2909,7 +2893,10 @@ if self.ppath and path == self.ppath: return "" else: - return self.ppathRe.sub("", path, 1) + p = path[len(self.ppath):] + if p.startswith(("\\","/")): + p = p[1:] + return p else: return path