12 import shutil |
12 import shutil |
13 import glob |
13 import glob |
14 import fnmatch |
14 import fnmatch |
15 import copy |
15 import copy |
16 import zipfile |
16 import zipfile |
17 import re |
|
18 |
17 |
19 from PyQt4.QtCore import QFile, QFileInfo, pyqtSignal, QCryptographicHash, QIODevice, \ |
18 from PyQt4.QtCore import QFile, QFileInfo, pyqtSignal, QCryptographicHash, QIODevice, \ |
20 QByteArray, QObject, Qt |
19 QByteArray, QObject, Qt |
21 from PyQt4.QtGui import QCursor, QLineEdit, QToolBar, QDialog, QInputDialog, \ |
20 from PyQt4.QtGui import QCursor, QLineEdit, QToolBar, QDialog, QInputDialog, \ |
22 QApplication, QMenu |
21 QApplication, QMenu |
390 """ |
389 """ |
391 self.loaded = False # flag for the loaded status |
390 self.loaded = False # flag for the loaded status |
392 self.__dirty = False # dirty flag |
391 self.__dirty = False # dirty flag |
393 self.pfile = "" # name of the project file |
392 self.pfile = "" # name of the project file |
394 self.ppath = "" # name of the project directory |
393 self.ppath = "" # name of the project directory |
395 self.ppathRe = None |
|
396 self.translationsRoot = "" # the translations prefix |
394 self.translationsRoot = "" # the translations prefix |
397 self.name = "" |
395 self.name = "" |
398 self.opened = False |
396 self.opened = False |
399 self.subdirs = [""] # record the project dir as a relative path (i.e. empty path) |
397 self.subdirs = [""] # record the project dir as a relative path (i.e. empty path) |
400 self.otherssubdirs = [] |
398 self.otherssubdirs = [] |
648 if removed: |
646 if removed: |
649 for file in removelist: |
647 for file in removelist: |
650 self.pdata[index].remove(file) |
648 self.pdata[index].remove(file) |
651 self.setDirty(True) |
649 self.setDirty(True) |
652 |
650 |
653 def __makePpathRe(self): |
|
654 """ |
|
655 Private method to generate a regular expression for the project path. |
|
656 """ |
|
657 ppathRe = (self.ppath + os.sep)\ |
|
658 .replace("\\", "@@")\ |
|
659 .replace("/", "@@")\ |
|
660 .replace("@@", r"[\\/]") |
|
661 if ppathRe.endswith(r"[\\/]"): |
|
662 ppathRe += "*" |
|
663 if Utilities.isWindowsPlatform(): |
|
664 self.ppathRe = re.compile(ppathRe, re.IGNORECASE) |
|
665 else: |
|
666 self.ppathRe = re.compile(ppathRe) |
|
667 |
|
668 def __readProject(self, fn): |
651 def __readProject(self, fn): |
669 """ |
652 """ |
670 Private method to read in a project (.e4p) file. |
653 Private method to read in a project (.e4p) file. |
671 |
654 |
672 @param fn filename of the project file to be read (string) |
655 @param fn filename of the project file to be read (string) |
1875 |
1856 |
1876 dlg = PropertiesDialog(self, True) |
1857 dlg = PropertiesDialog(self, True) |
1877 if dlg.exec_() == QDialog.Accepted: |
1858 if dlg.exec_() == QDialog.Accepted: |
1878 self.closeProject() |
1859 self.closeProject() |
1879 dlg.storeData() |
1860 dlg.storeData() |
1880 self.__makePpathRe() |
|
1881 self.pdata["VCS"] = ['None'] |
1861 self.pdata["VCS"] = ['None'] |
1882 self.opened = True |
1862 self.opened = True |
1883 if not self.pdata["FILETYPES"]: |
1863 if not self.pdata["FILETYPES"]: |
1884 self.initFileTypes() |
1864 self.initFileTypes() |
1885 self.setDirty(True) |
1865 self.setDirty(True) |
2846 """ |
2826 """ |
2847 Public method to check, if a path starts with the project path. |
2827 Public method to check, if a path starts with the project path. |
2848 |
2828 |
2849 @param path path to be checked (string) |
2829 @param path path to be checked (string) |
2850 """ |
2830 """ |
2851 if self.ppath and path == self.ppath: |
2831 if self.ppath: |
2852 return True |
2832 if path == self.ppath: |
2853 elif self.ppathRe: |
2833 return True |
2854 return self.ppathRe.match(path) is not None |
2834 elif Utilities.normcasepath(Utilities.toNativeSeparators(path)).startswith( |
|
2835 Utilities.normcasepath(Utilities.toNativeSeparators(self.ppath))): |
|
2836 return True |
|
2837 else: |
|
2838 return False |
2855 else: |
2839 else: |
2856 return False |
2840 return False |
2857 |
2841 |
2858 def getProjectFile(self): |
2842 def getProjectFile(self): |
2859 """ |
2843 """ |
2907 """ |
2891 """ |
2908 if self.startswithProjectPath(path): |
2892 if self.startswithProjectPath(path): |
2909 if self.ppath and path == self.ppath: |
2893 if self.ppath and path == self.ppath: |
2910 return "" |
2894 return "" |
2911 else: |
2895 else: |
2912 return self.ppathRe.sub("", path, 1) |
2896 p = path[len(self.ppath):] |
|
2897 if p.startswith(("\\","/")): |
|
2898 p = p[1:] |
|
2899 return p |
2913 else: |
2900 else: |
2914 return path |
2901 return path |
2915 |
2902 |
2916 def getRelativeUniversalPath(self, path): |
2903 def getRelativeUniversalPath(self, path): |
2917 """ |
2904 """ |