src/eric7/Project/Project.py

branch
eric7-maintenance
changeset 10616
4aa36fcd4a30
parent 10534
783d835d7fe4
parent 10611
60c838d75276
child 10659
43ead32943ca
equal deleted inserted replaced
10558:e3381757d40d 10616:4aa36fcd4a30
21 21
22 from PyQt6.Qsci import QsciScintilla 22 from PyQt6.Qsci import QsciScintilla
23 from PyQt6.QtCore import ( 23 from PyQt6.QtCore import (
24 QByteArray, 24 QByteArray,
25 QCryptographicHash, 25 QCryptographicHash,
26 QFile,
27 QIODevice,
28 QObject, 26 QObject,
29 QProcess, 27 QProcess,
30 pyqtSignal, 28 pyqtSignal,
31 pyqtSlot, 29 pyqtSlot,
32 ) 30 )
43 from eric7.EricGui.EricOverrideCursor import EricOverrideCursor, EricOverridenCursor 41 from eric7.EricGui.EricOverrideCursor import EricOverrideCursor, EricOverridenCursor
44 from eric7.EricWidgets import EricFileDialog, EricMessageBox 42 from eric7.EricWidgets import EricFileDialog, EricMessageBox
45 from eric7.EricWidgets.EricApplication import ericApp 43 from eric7.EricWidgets.EricApplication import ericApp
46 from eric7.EricWidgets.EricListSelectionDialog import EricListSelectionDialog 44 from eric7.EricWidgets.EricListSelectionDialog import EricListSelectionDialog
47 from eric7.EricWidgets.EricProgressDialog import EricProgressDialog 45 from eric7.EricWidgets.EricProgressDialog import EricProgressDialog
48 from eric7.EricXML.DebuggerPropertiesReader import DebuggerPropertiesReader
49 from eric7.EricXML.ProjectReader import ProjectReader
50 from eric7.EricXML.SessionReader import SessionReader
51 from eric7.EricXML.TasksReader import TasksReader
52 from eric7.EricXML.UserProjectReader import UserProjectReader
53 from eric7.Globals import recentNameProject 46 from eric7.Globals import recentNameProject
54 from eric7.Sessions.SessionFile import SessionFile 47 from eric7.Sessions.SessionFile import SessionFile
55 from eric7.SystemUtilities import ( 48 from eric7.SystemUtilities import (
56 FileSystemUtilities, 49 FileSystemUtilities,
57 OSUtilities, 50 OSUtilities,
549 "AUTHOR": "", 542 "AUTHOR": "",
550 "EMAIL": "", 543 "EMAIL": "",
551 "HASH": "", 544 "HASH": "",
552 "PROGLANGUAGE": "Python3", 545 "PROGLANGUAGE": "Python3",
553 "MIXEDLANGUAGE": False, 546 "MIXEDLANGUAGE": False,
554 "PROJECTTYPE": "PyQt5", 547 "PROJECTTYPE": "PyQt6",
555 "SPELLLANGUAGE": Preferences.getEditor("SpellCheckingDefaultLanguage"), 548 "SPELLLANGUAGE": Preferences.getEditor("SpellCheckingDefaultLanguage"),
556 "SPELLWORDS": "", 549 "SPELLWORDS": "",
557 "SPELLEXCLUDES": "", 550 "SPELLEXCLUDES": "",
558 "FILETYPES": {}, 551 "FILETYPES": {},
559 "LEXERASSOCS": {}, 552 "LEXERASSOCS": {},
873 "*.txt": "OTHERS", 866 "*.txt": "OTHERS",
874 "*.md": "OTHERS", 867 "*.md": "OTHERS",
875 "*.rst": "OTHERS", 868 "*.rst": "OTHERS",
876 "README": "OTHERS", 869 "README": "OTHERS",
877 "README.*": "OTHERS", 870 "README.*": "OTHERS",
878 "*.e4p": "OTHERS",
879 "*.epj": "OTHERS", 871 "*.epj": "OTHERS",
880 "GNUmakefile": "OTHERS", 872 "GNUmakefile": "OTHERS",
881 "makefile": "OTHERS", 873 "makefile": "OTHERS",
882 "Makefile": "OTHERS", 874 "Makefile": "OTHERS",
883 "*.ini": "OTHERS", 875 "*.ini": "OTHERS",
1116 self.__pdata[index].remove(file) 1108 self.__pdata[index].remove(file)
1117 self.setDirty(True) 1109 self.setDirty(True)
1118 1110
1119 def __readProject(self, fn): 1111 def __readProject(self, fn):
1120 """ 1112 """
1121 Private method to read in a project (.epj or .e4p) file. 1113 Private method to read in a project (.epj) file.
1122 1114
1123 @param fn filename of the project file to be read 1115 @param fn filename of the project file to be read
1124 @type str 1116 @type str
1125 @return flag indicating success 1117 @return flag indicating success
1126 @rtype bool 1118 @rtype bool
1127 """ 1119 """
1128 if os.path.splitext(fn)[1] == ".epj": 1120 with EricOverrideCursor():
1129 # new JSON based format 1121 res = self.__projectFile.readFile(fn)
1130 with EricOverrideCursor():
1131 res = self.__projectFile.readFile(fn)
1132 else:
1133 # old XML based format
1134 f = QFile(fn)
1135 if f.open(QIODevice.OpenModeFlag.ReadOnly):
1136 reader = ProjectReader(f, self)
1137 reader.readXML()
1138 res = not reader.hasError()
1139 f.close()
1140
1141 # create hash value, if it doesn't have one
1142 if reader.version.startswith("5.") and not self.__pdata["HASH"]:
1143 hashStr = str(
1144 QCryptographicHash.hash(
1145 QByteArray(self.ppath.encode("utf-8")),
1146 QCryptographicHash.Algorithm.Sha1,
1147 ).toHex(),
1148 encoding="utf-8",
1149 )
1150 self.__pdata["HASH"] = hashStr
1151 self.setDirty(True)
1152 else:
1153 EricMessageBox.critical(
1154 self.ui,
1155 self.tr("Read Project File"),
1156 self.tr(
1157 "<p>The project file <b>{0}</b> could not be read.</p>"
1158 ).format(fn),
1159 )
1160 res = False
1161 1122
1162 if res: 1123 if res:
1163 self.pfile = os.path.abspath(fn) 1124 self.pfile = os.path.abspath(fn)
1164 self.ppath = os.path.abspath(os.path.dirname(fn)) 1125 self.ppath = os.path.abspath(os.path.dirname(fn))
1165 1126
1245 1206
1246 return res 1207 return res
1247 1208
1248 def __readUserProperties(self): 1209 def __readUserProperties(self):
1249 """ 1210 """
1250 Private method to read in the user specific project file (.eqj or 1211 Private method to read in the user specific project file (.eqj).
1251 .e4q).
1252 """ 1212 """
1253 if self.pfile is None: 1213 if self.pfile is None:
1254 return 1214 return
1255 1215
1256 fn1, ext = os.path.splitext(os.path.basename(self.pfile)) 1216 fn1, ext = os.path.splitext(os.path.basename(self.pfile))
1257 fn = os.path.join(self.getProjectManagementDir(), "{0}.eqj".format(fn1)) 1217 fn = os.path.join(self.getProjectManagementDir(), "{0}.eqj".format(fn1))
1258 if os.path.exists(fn): 1218 if os.path.exists(fn):
1259 # try the new JSON based format first
1260 self.__userProjectFile.readFile(fn) 1219 self.__userProjectFile.readFile(fn)
1261 else:
1262 # try the old XML based format second
1263 fn = os.path.join(self.getProjectManagementDir(), "{0}.e4q".format(fn1))
1264 if os.path.exists(fn):
1265 f = QFile(fn)
1266 if f.open(QIODevice.OpenModeFlag.ReadOnly):
1267 reader = UserProjectReader(f, self)
1268 reader.readXML()
1269 f.close()
1270 else:
1271 EricMessageBox.critical(
1272 self.ui,
1273 self.tr("Read User Project Properties"),
1274 self.tr(
1275 "<p>The user specific project properties file"
1276 " <b>{0}</b> could not be read.</p>"
1277 ).format(fn),
1278 )
1279 1220
1280 def __writeUserProperties(self): 1221 def __writeUserProperties(self):
1281 """ 1222 """
1282 Private method to write the user specific project data to a JSON file. 1223 Private method to write the user specific project data to a JSON file.
1283 """ 1224 """
1297 enable = True 1238 enable = True
1298 if self.pfile is None: 1239 if self.pfile is None:
1299 enable = False 1240 enable = False
1300 else: 1241 else:
1301 fn, ext = os.path.splitext(os.path.basename(self.pfile)) 1242 fn, ext = os.path.splitext(os.path.basename(self.pfile))
1302 fn_new = os.path.join(self.getProjectManagementDir(), "{0}.esj".format(fn)) 1243 fn_sess = os.path.join(self.getProjectManagementDir(), "{0}.esj".format(fn))
1303 fn_old = os.path.join(self.getProjectManagementDir(), "{0}.e5s".format(fn)) 1244 enable = os.path.exists(fn_sess)
1304 enable = os.path.exists(fn_new) or os.path.exists(fn_old)
1305 self.sessActGrp.findChild(QAction, "project_load_session").setEnabled(enable) 1245 self.sessActGrp.findChild(QAction, "project_load_session").setEnabled(enable)
1306 self.sessActGrp.findChild(QAction, "project_delete_session").setEnabled(enable) 1246 self.sessActGrp.findChild(QAction, "project_delete_session").setEnabled(enable)
1307 1247
1308 @pyqtSlot() 1248 @pyqtSlot()
1309 def __readSession(self, quiet=False, indicator=""): 1249 def __readSession(self, quiet=False, indicator=""):
1310 """ 1250 """
1311 Private method to read in the project session file (.esj or .e5s). 1251 Private method to read in the project session file (.esj).
1312 1252
1313 @param quiet flag indicating quiet operations. 1253 @param quiet flag indicating quiet operations.
1314 If this flag is true, no errors are reported. 1254 If this flag is true, no errors are reported.
1315 @type bool 1255 @type bool
1316 @param indicator indicator string 1256 @param indicator indicator string
1328 fn1, ext = os.path.splitext(os.path.basename(self.pfile)) 1268 fn1, ext = os.path.splitext(os.path.basename(self.pfile))
1329 fn = os.path.join( 1269 fn = os.path.join(
1330 self.getProjectManagementDir(), "{0}{1}.esj".format(fn1, indicator) 1270 self.getProjectManagementDir(), "{0}{1}.esj".format(fn1, indicator)
1331 ) 1271 )
1332 if os.path.exists(fn): 1272 if os.path.exists(fn):
1333 # try the new JSON based format first
1334 self.__sessionFile.readFile(fn) 1273 self.__sessionFile.readFile(fn)
1335 else:
1336 # try the old XML based format second
1337 fn = os.path.join(
1338 self.getProjectManagementDir(), "{0}{1}.e5s".format(fn1, indicator)
1339 )
1340 if os.path.exists(fn):
1341 f = QFile(fn)
1342 if f.open(QIODevice.OpenModeFlag.ReadOnly):
1343 reader = SessionReader(f, False)
1344 reader.readXML(quiet=quiet)
1345 f.close()
1346 else:
1347 if not quiet:
1348 EricMessageBox.critical(
1349 self.ui,
1350 self.tr("Read project session"),
1351 self.tr(
1352 "<p>The project session file <b>{0}</b> could"
1353 " not be read.</p>"
1354 ).format(fn),
1355 )
1356 1274
1357 @pyqtSlot() 1275 @pyqtSlot()
1358 def __writeSession(self, quiet=False, indicator=""): 1276 def __writeSession(self, quiet=False, indicator=""):
1359 """ 1277 """
1360 Private method to write the session data to an XML file (.esj). 1278 Private method to write the session data to an XML file (.esj).
1393 ) 1311 )
1394 return 1312 return
1395 1313
1396 fname, ext = os.path.splitext(os.path.basename(self.pfile)) 1314 fname, ext = os.path.splitext(os.path.basename(self.pfile))
1397 1315
1398 for ext in (".esj", ".e5s", ".e4s"): 1316 fn = os.path.join(self.getProjectManagementDir(), f"{fname}.esj")
1399 fn = os.path.join( 1317 if os.path.exists(fn):
1400 self.getProjectManagementDir(), "{0}{1}".format(fname, ext) 1318 try:
1401 ) 1319 os.remove(fn)
1402 if os.path.exists(fn): 1320 except OSError:
1403 try: 1321 EricMessageBox.critical(
1404 os.remove(fn) 1322 self.ui,
1405 except OSError: 1323 self.tr("Delete Project Session"),
1406 EricMessageBox.critical( 1324 self.tr(
1407 self.ui, 1325 "<p>The project session file <b>{0}</b> could"
1408 self.tr("Delete Project Session"), 1326 " not be deleted.</p>"
1409 self.tr( 1327 ).format(fn),
1410 "<p>The project session file <b>{0}</b> could" 1328 )
1411 " not be deleted.</p>"
1412 ).format(fn),
1413 )
1414 1329
1415 def __readTasks(self): 1330 def __readTasks(self):
1416 """ 1331 """
1417 Private method to read in the project tasks file (.etj or .e6t). 1332 Private method to read in the project tasks file (.etj).
1418 """ 1333 """
1419 if self.pfile is None: 1334 if self.pfile is None:
1420 EricMessageBox.critical( 1335 EricMessageBox.critical(
1421 self.ui, 1336 self.ui,
1422 self.tr("Read Tasks"), 1337 self.tr("Read Tasks"),
1425 return 1340 return
1426 1341
1427 base, ext = os.path.splitext(os.path.basename(self.pfile)) 1342 base, ext = os.path.splitext(os.path.basename(self.pfile))
1428 fn = os.path.join(self.getProjectManagementDir(), "{0}.etj".format(base)) 1343 fn = os.path.join(self.getProjectManagementDir(), "{0}.etj".format(base))
1429 if os.path.exists(fn): 1344 if os.path.exists(fn):
1430 # try new style JSON file first
1431 self.__tasksFile.readFile(fn) 1345 self.__tasksFile.readFile(fn)
1432 else:
1433 # try old style XML file second
1434 fn = os.path.join(self.getProjectManagementDir(), "{0}.e6t".format(base))
1435 if os.path.exists(fn):
1436 f = QFile(fn)
1437 if f.open(QIODevice.OpenModeFlag.ReadOnly):
1438 reader = TasksReader(f, True)
1439 reader.readXML()
1440 f.close()
1441 else:
1442 EricMessageBox.critical(
1443 self.ui,
1444 self.tr("Read Tasks"),
1445 self.tr(
1446 "<p>The tasks file <b>{0}</b> could not be read.</p>"
1447 ).format(fn),
1448 )
1449 1346
1450 def writeTasks(self): 1347 def writeTasks(self):
1451 """ 1348 """
1452 Public method to write the tasks data to a JSON file (.etj). 1349 Public method to write the tasks data to a JSON file (.etj).
1453 """ 1350 """
1466 enable = True 1363 enable = True
1467 if self.pfile is None: 1364 if self.pfile is None:
1468 enable = False 1365 enable = False
1469 else: 1366 else:
1470 fn, ext = os.path.splitext(os.path.basename(self.pfile)) 1367 fn, ext = os.path.splitext(os.path.basename(self.pfile))
1471 # try new style file first
1472 fn = os.path.join(self.getProjectManagementDir(), "{0}.edj".format(fn)) 1368 fn = os.path.join(self.getProjectManagementDir(), "{0}.edj".format(fn))
1473 if not os.path.exists(fn):
1474 # try old style file second
1475 fn = os.path.join(self.getProjectManagementDir(), "{0}.e4d".format(fn))
1476 enable = os.path.exists(fn) 1369 enable = os.path.exists(fn)
1477 self.dbgActGrp.findChild( 1370 self.dbgActGrp.findChild(
1478 QAction, "project_debugger_properties_load" 1371 QAction, "project_debugger_properties_load"
1479 ).setEnabled(enable) 1372 ).setEnabled(enable)
1480 self.dbgActGrp.findChild( 1373 self.dbgActGrp.findChild(
1482 ).setEnabled(enable) 1375 ).setEnabled(enable)
1483 1376
1484 @pyqtSlot() 1377 @pyqtSlot()
1485 def __readDebugProperties(self, quiet=False): 1378 def __readDebugProperties(self, quiet=False):
1486 """ 1379 """
1487 Private method to read in the project debugger properties file 1380 Private method to read in the project debugger properties file (.edj).
1488 (.edj or .e4d).
1489 1381
1490 @param quiet flag indicating quiet operations. 1382 @param quiet flag indicating quiet operations.
1491 If this flag is true, no errors are reported. 1383 If this flag is true, no errors are reported.
1492 @type bool 1384 @type bool
1493 """ 1385 """
1500 ) 1392 )
1501 return 1393 return
1502 1394
1503 fn1, ext = os.path.splitext(os.path.basename(self.pfile)) 1395 fn1, ext = os.path.splitext(os.path.basename(self.pfile))
1504 fn = os.path.join(self.getProjectManagementDir(), "{0}.edj".format(fn1)) 1396 fn = os.path.join(self.getProjectManagementDir(), "{0}.edj".format(fn1))
1505 if os.path.exists(fn): 1397 if (
1506 # try the new JSON based format first 1398 os.path.exists(fn)
1507 if self.__debuggerPropertiesFile.readFile(fn): 1399 and self.__debuggerPropertiesFile.readFile(fn)
1508 self.debugPropertiesLoaded = True 1400 ):
1509 self.debugPropertiesChanged = False 1401 self.debugPropertiesLoaded = True
1510 else: 1402 self.debugPropertiesChanged = False
1511 # try the old XML based format second
1512 fn = os.path.join(self.getProjectManagementDir(), "{0}.e4d".format(fn1))
1513
1514 f = QFile(fn)
1515 if f.open(QIODevice.OpenModeFlag.ReadOnly):
1516 reader = DebuggerPropertiesReader(f, self)
1517 reader.readXML(quiet=quiet)
1518 f.close()
1519 self.debugPropertiesLoaded = True
1520 self.debugPropertiesChanged = False
1521 else:
1522 if not quiet:
1523 EricMessageBox.critical(
1524 self.ui,
1525 self.tr("Read Debugger Properties"),
1526 self.tr(
1527 "<p>The project debugger properties file"
1528 " <b>{0}</b> could not be read.</p>"
1529 ).format(fn),
1530 )
1531 1403
1532 @pyqtSlot() 1404 @pyqtSlot()
1533 def __writeDebugProperties(self, quiet=False): 1405 def __writeDebugProperties(self, quiet=False):
1534 """ 1406 """
1535 Private method to write the project debugger properties file (.edj). 1407 Private method to write the project debugger properties file (.edj).
1553 with EricOverrideCursor(): 1425 with EricOverrideCursor():
1554 self.__debuggerPropertiesFile.writeFile(fn) 1426 self.__debuggerPropertiesFile.writeFile(fn)
1555 1427
1556 def __deleteDebugProperties(self): 1428 def __deleteDebugProperties(self):
1557 """ 1429 """
1558 Private method to delete the project debugger properties file 1430 Private method to delete the project debugger properties file (.edj).
1559 (.edj or .e4d).
1560 """ 1431 """
1561 if self.pfile is None: 1432 if self.pfile is None:
1562 EricMessageBox.critical( 1433 EricMessageBox.critical(
1563 self.ui, 1434 self.ui,
1564 self.tr("Delete Debugger Properties"), 1435 self.tr("Delete Debugger Properties"),
1566 ) 1437 )
1567 return 1438 return
1568 1439
1569 fname, ext = os.path.splitext(os.path.basename(self.pfile)) 1440 fname, ext = os.path.splitext(os.path.basename(self.pfile))
1570 1441
1571 for ext in (".edj", ".e4d"): 1442 fn = os.path.join(self.getProjectManagementDir(), f"{fname}.edj")
1572 fn = os.path.join( 1443 if os.path.exists(fn):
1573 self.getProjectManagementDir(), "{0}{1}".format(fname, ext) 1444 try:
1574 ) 1445 os.remove(fn)
1575 if os.path.exists(fn): 1446 except OSError:
1576 try: 1447 EricMessageBox.critical(
1577 os.remove(fn) 1448 self.ui,
1578 except OSError: 1449 self.tr("Delete Debugger Properties"),
1579 EricMessageBox.critical( 1450 self.tr(
1580 self.ui, 1451 "<p>The project debugger properties file"
1581 self.tr("Delete Debugger Properties"), 1452 " <b>{0}</b> could not be deleted.</p>"
1582 self.tr( 1453 ).format(fn),
1583 "<p>The project debugger properties file" 1454 )
1584 " <b>{0}</b> could not be deleted.</p>"
1585 ).format(fn),
1586 )
1587 1455
1588 def __initDebugProperties(self): 1456 def __initDebugProperties(self):
1589 """ 1457 """
1590 Private method to initialize the debug properties. 1458 Private method to initialize the debug properties.
1591 """ 1459 """
2251 newfn = EricFileDialog.getSaveFileName( 2119 newfn = EricFileDialog.getSaveFileName(
2252 None, 2120 None,
2253 self.tr("Rename file"), 2121 self.tr("Rename file"),
2254 oldfn, 2122 oldfn,
2255 "", 2123 "",
2256 EricFileDialog.DontConfirmOverwrite, 2124 options=EricFileDialog.DontConfirmOverwrite,
2257 ) 2125 )
2258 if not newfn: 2126 if not newfn:
2259 return False 2127 return False
2260 newfn = FileSystemUtilities.toNativeSeparators(newfn) 2128 newfn = FileSystemUtilities.toNativeSeparators(newfn)
2261 2129
2717 ms = os.path.join(self.ppath, self.__pdata["MAINSCRIPT"]) 2585 ms = os.path.join(self.ppath, self.__pdata["MAINSCRIPT"])
2718 else: 2586 else:
2719 ms = self.__pdata["MAINSCRIPT"] 2587 ms = self.__pdata["MAINSCRIPT"]
2720 if not os.path.exists(ms): 2588 if not os.path.exists(ms):
2721 try: 2589 try:
2722 os.makedirs(os.path.dirname(ms)) 2590 os.makedirs(os.path.dirname(ms), exist_ok=True)
2723 with open(ms, "w"): 2591 with open(ms, "w"):
2724 pass 2592 pass
2725 except OSError as err: 2593 except OSError as err:
2726 EricMessageBox.critical( 2594 EricMessageBox.critical(
2727 self.ui, 2595 self.ui,
2742 mf = os.path.join(self.ppath, mf) 2610 mf = os.path.join(self.ppath, mf)
2743 else: 2611 else:
2744 mf = os.path.join(self.ppath, Project.DefaultMakefile) 2612 mf = os.path.join(self.ppath, Project.DefaultMakefile)
2745 if not os.path.exists(mf): 2613 if not os.path.exists(mf):
2746 try: 2614 try:
2747 os.makedirs(os.path.dirname(mf)) 2615 os.makedirs(os.path.dirname(mf), exist_ok=True)
2748 with open(mf, "w"): 2616 with open(mf, "w"):
2749 pass 2617 pass
2750 except OSError as err: 2618 except OSError as err:
2751 EricMessageBox.critical( 2619 EricMessageBox.critical(
2752 self.ui, 2620 self.ui,
3245 if fn is None: 3113 if fn is None:
3246 fn = EricFileDialog.getOpenFileName( 3114 fn = EricFileDialog.getOpenFileName(
3247 self.parent(), 3115 self.parent(),
3248 self.tr("Open project"), 3116 self.tr("Open project"),
3249 Preferences.getMultiProject("Workspace") or OSUtilities.getHomeDir(), 3117 Preferences.getMultiProject("Workspace") or OSUtilities.getHomeDir(),
3250 self.tr("Project Files (*.epj);;XML Project Files (*.e4p)"), 3118 self.tr("Project Files (*.epj)"),
3251 ) 3119 )
3252 3120
3253 if fn and self.closeProject(): 3121 if fn and self.closeProject():
3254 with EricOverrideCursor(): 3122 with EricOverrideCursor():
3255 ok = self.__readProject(fn) 3123 ok = self.__readProject(fn)
3421 @return flag indicating success 3289 @return flag indicating success
3422 @rtype bool 3290 @rtype bool
3423 """ 3291 """
3424 if self.isDirty(): 3292 if self.isDirty():
3425 if len(self.pfile) > 0: 3293 if len(self.pfile) > 0:
3426 if self.pfile.endswith(".e4p"):
3427 self.pfile = self.pfile.replace(".e4p", ".epj")
3428 self.__syncRecent()
3429 ok = self.__writeProject() 3294 ok = self.__writeProject()
3430 else: 3295 else:
3431 ok = self.saveProjectAs() 3296 ok = self.saveProjectAs()
3432 else: 3297 else:
3433 ok = True 3298 ok = True
5684 pattern 5549 pattern
5685 for pattern, filetype in self.__pdata["FILETYPES"].items() 5550 for pattern, filetype in self.__pdata["FILETYPES"].items()
5686 if filetype == "__IGNORE__" 5551 if filetype == "__IGNORE__"
5687 ] 5552 ]
5688 5553
5689 dirs = self.subdirs[:] 5554 dirs = [""] if recursiveSearch else self.subdirs[:] + [""]
5690 for directory in dirs: 5555 for directory in dirs:
5691 skip = False 5556 skip = False
5692 for ignore_pattern in ignore_patterns: 5557 for ignore_pattern in ignore_patterns:
5693 if fnmatch.fnmatch(directory, ignore_pattern): 5558 if fnmatch.fnmatch(directory, ignore_pattern):
5694 skip = True 5559 skip = True
5707 else "*.ts" 5572 else "*.ts"
5708 ) 5573 )
5709 binpattern = self.__binaryTranslationFile(pattern) 5574 binpattern = self.__binaryTranslationFile(pattern)
5710 for ns in newSources: 5575 for ns in newSources:
5711 # ignore hidden files and directories 5576 # ignore hidden files and directories
5712 if ns.startswith("."): 5577 if ns.startswith(".") or ns == "__pycache__":
5713 continue
5714 if (
5715 OSUtilities.isWindowsPlatform()
5716 and os.path.isdir(os.path.join(curpath, ns))
5717 and ns.startswith("_")
5718 ):
5719 # dot net hack
5720 continue 5578 continue
5721 5579
5722 # set fn to project relative name 5580 # set fn to project relative name
5723 # then reset ns to fully qualified name for insertion, 5581 # then reset ns to fully qualified name for insertion,
5724 # possibly. 5582 # possibly.
7105 Private method to find the path of the embedded virtual environment. 6963 Private method to find the path of the embedded virtual environment.
7106 6964
7107 @return path of the embedded virtual environment (empty if not found) 6965 @return path of the embedded virtual environment (empty if not found)
7108 @rtype str 6966 @rtype str
7109 """ 6967 """
7110 with os.scandir(self.getProjectPath()) as ppathDirEntriesIterator: 6968 ppath = self.getProjectPath()
7111 for dirEntry in ppathDirEntriesIterator: 6969 if ppath and os.path.exists(ppath):
7112 # potential venv directory; check for 'pyvenv.cfg' 6970 with os.scandir(self.getProjectPath()) as ppathDirEntriesIterator:
7113 if dirEntry.is_dir() and os.path.exists( 6971 for dirEntry in ppathDirEntriesIterator:
7114 os.path.join(dirEntry.path, "pyvenv.cfg") 6972 # potential venv directory; check for 'pyvenv.cfg'
7115 ): 6973 if dirEntry.is_dir() and os.path.exists(
7116 return dirEntry.path 6974 os.path.join(dirEntry.path, "pyvenv.cfg")
7117 6975 ):
7118 # check for some common names in case 'pyvenv.cfg' is missing 6976 return dirEntry.path
7119 for venvPathName in (".venv", "venv", ".env", "env"): 6977
7120 venvPath = os.path.join(self.getProjectPath(), venvPathName) 6978 # check for some common names in case 'pyvenv.cfg' is missing
7121 if os.path.isdir(venvPath): 6979 for venvPathName in (".venv", "venv", ".env", "env"):
7122 return venvPath 6980 venvPath = os.path.join(self.getProjectPath(), venvPathName)
6981 if os.path.isdir(venvPath):
6982 return venvPath
7123 6983
7124 return "" 6984 return ""
7125 6985
7126 def __setEmbeddedEnvironmentProjectConfig(self, value): 6986 def __setEmbeddedEnvironmentProjectConfig(self, value):
7127 """ 6987 """

eric ide

mercurial