1466 |
1466 |
1467 try: |
1467 try: |
1468 fn = os.path.join(self.ppath, langFile) |
1468 fn = os.path.join(self.ppath, langFile) |
1469 if os.path.exists(fn): |
1469 if os.path.exists(fn): |
1470 s2t(fn) |
1470 s2t(fn) |
1471 except EnvironmentError as err: |
1471 except OSError as err: |
1472 E5MessageBox.critical( |
1472 E5MessageBox.critical( |
1473 self.ui, |
1473 self.ui, |
1474 self.tr("Delete translation"), |
1474 self.tr("Delete translation"), |
1475 self.tr( |
1475 self.tr( |
1476 "<p>The selected translation file <b>{0}</b> could not be" |
1476 "<p>The selected translation file <b>{0}</b> could not be" |
1488 os.path.join(self.pdata["TRANSLATIONSBINPATH"], |
1488 os.path.join(self.pdata["TRANSLATIONSBINPATH"], |
1489 os.path.basename(qmFile))) |
1489 os.path.basename(qmFile))) |
1490 fn = os.path.join(self.ppath, qmFile) |
1490 fn = os.path.join(self.ppath, qmFile) |
1491 if os.path.exists(fn): |
1491 if os.path.exists(fn): |
1492 s2t(fn) |
1492 s2t(fn) |
1493 except EnvironmentError as err: |
1493 except OSError as err: |
1494 E5MessageBox.critical( |
1494 E5MessageBox.critical( |
1495 self.ui, |
1495 self.ui, |
1496 self.tr("Delete translation"), |
1496 self.tr("Delete translation"), |
1497 self.tr( |
1497 self.tr( |
1498 "<p>The selected translation file <b>{0}</b> could" |
1498 "<p>The selected translation file <b>{0}</b> could" |
1640 icon=E5MessageBox.Warning) |
1640 icon=E5MessageBox.Warning) |
1641 if not res: |
1641 if not res: |
1642 return # don't overwrite |
1642 return # don't overwrite |
1643 |
1643 |
1644 shutil.copy(fn, target) |
1644 shutil.copy(fn, target) |
1645 except IOError as why: |
1645 except OSError as why: |
1646 E5MessageBox.critical( |
1646 E5MessageBox.critical( |
1647 self.ui, |
1647 self.ui, |
1648 self.tr("Add file"), |
1648 self.tr("Add file"), |
1649 self.tr( |
1649 self.tr( |
1650 "<p>The selected file <b>{0}</b> could" |
1650 "<p>The selected file <b>{0}</b> could" |
1699 not Utilities.samepath(target, source) and |
1699 not Utilities.samepath(target, source) and |
1700 not os.path.isdir(target) |
1700 not os.path.isdir(target) |
1701 ): |
1701 ): |
1702 try: |
1702 try: |
1703 os.makedirs(target) |
1703 os.makedirs(target) |
1704 except IOError as why: |
1704 except OSError as why: |
1705 E5MessageBox.critical( |
1705 E5MessageBox.critical( |
1706 self.ui, |
1706 self.ui, |
1707 self.tr("Add directory"), |
1707 self.tr("Add directory"), |
1708 self.tr( |
1708 self.tr( |
1709 "<p>The target directory <b>{0}</b> could not be" |
1709 "<p>The target directory <b>{0}</b> could not be" |
1731 if not res: |
1731 if not res: |
1732 continue |
1732 continue |
1733 # don't overwrite, carry on with next file |
1733 # don't overwrite, carry on with next file |
1734 |
1734 |
1735 shutil.copy(file, target) |
1735 shutil.copy(file, target) |
1736 except EnvironmentError: |
1736 except OSError: |
1737 continue |
1737 continue |
1738 self.appendFile(targetfile) |
1738 self.appendFile(targetfile) |
1739 |
1739 |
1740 def __addRecursiveDirectory(self, filetype, source, target): |
1740 def __addRecursiveDirectory(self, filetype, source, target): |
1741 """ |
1741 """ |
2207 pat = os.path.join( |
2207 pat = os.path.join( |
2208 self.ppath, head, |
2208 self.ppath, head, |
2209 "__pycache__", "{0}.*{1}".format(tail, ext)) |
2209 "__pycache__", "{0}.*{1}".format(tail, ext)) |
2210 for f in glob.glob(pat): |
2210 for f in glob.glob(pat): |
2211 s2t(f) |
2211 s2t(f) |
2212 except EnvironmentError as err: |
2212 except OSError as err: |
2213 E5MessageBox.critical( |
2213 E5MessageBox.critical( |
2214 self.ui, |
2214 self.ui, |
2215 self.tr("Delete file"), |
2215 self.tr("Delete file"), |
2216 self.tr( |
2216 self.tr( |
2217 "<p>The selected file <b>{0}</b> could not be" |
2217 "<p>The selected file <b>{0}</b> could not be" |
2237 try: |
2237 try: |
2238 from ThirdParty.Send2Trash.send2trash import send2trash |
2238 from ThirdParty.Send2Trash.send2trash import send2trash |
2239 send2trash(dn) |
2239 send2trash(dn) |
2240 except ImportError: |
2240 except ImportError: |
2241 shutil.rmtree(dn, True) |
2241 shutil.rmtree(dn, True) |
2242 except EnvironmentError as err: |
2242 except OSError as err: |
2243 E5MessageBox.critical( |
2243 E5MessageBox.critical( |
2244 self.ui, |
2244 self.ui, |
2245 self.tr("Delete directory"), |
2245 self.tr("Delete directory"), |
2246 self.tr( |
2246 self.tr( |
2247 "<p>The selected directory <b>{0}</b> could not be" |
2247 "<p>The selected directory <b>{0}</b> could not be" |
2332 |
2332 |
2333 # create the project directory if it doesn't exist already |
2333 # create the project directory if it doesn't exist already |
2334 if not os.path.isdir(self.ppath): |
2334 if not os.path.isdir(self.ppath): |
2335 try: |
2335 try: |
2336 os.makedirs(self.ppath) |
2336 os.makedirs(self.ppath) |
2337 except EnvironmentError: |
2337 except OSError: |
2338 E5MessageBox.critical( |
2338 E5MessageBox.critical( |
2339 self.ui, |
2339 self.ui, |
2340 self.tr("Create project directory"), |
2340 self.tr("Create project directory"), |
2341 self.tr( |
2341 self.tr( |
2342 "<p>The project directory <b>{0}</b> could not" |
2342 "<p>The project directory <b>{0}</b> could not" |
2397 addAllToVcs = True |
2397 addAllToVcs = True |
2398 else: |
2398 else: |
2399 try: |
2399 try: |
2400 # create management directory if not present |
2400 # create management directory if not present |
2401 self.createProjectManagementDir() |
2401 self.createProjectManagementDir() |
2402 except EnvironmentError: |
2402 except OSError: |
2403 E5MessageBox.critical( |
2403 E5MessageBox.critical( |
2404 self.ui, |
2404 self.ui, |
2405 self.tr("Create project management directory"), |
2405 self.tr("Create project management directory"), |
2406 self.tr( |
2406 self.tr( |
2407 "<p>The project directory <b>{0}</b> is not" |
2407 "<p>The project directory <b>{0}</b> is not" |
2418 if not os.path.exists(ms): |
2418 if not os.path.exists(ms): |
2419 try: |
2419 try: |
2420 os.makedirs(os.path.dirname(ms)) |
2420 os.makedirs(os.path.dirname(ms)) |
2421 with open(ms, "w"): |
2421 with open(ms, "w"): |
2422 pass |
2422 pass |
2423 except EnvironmentError as err: |
2423 except OSError as err: |
2424 E5MessageBox.critical( |
2424 E5MessageBox.critical( |
2425 self.ui, |
2425 self.ui, |
2426 self.tr("Create main script"), |
2426 self.tr("Create main script"), |
2427 self.tr( |
2427 self.tr( |
2428 "<p>The mainscript <b>{0}</b> could not" |
2428 "<p>The mainscript <b>{0}</b> could not" |
2442 if not os.path.exists(mf): |
2442 if not os.path.exists(mf): |
2443 try: |
2443 try: |
2444 os.makedirs(os.path.dirname(mf)) |
2444 os.makedirs(os.path.dirname(mf)) |
2445 with open(mf, "w"): |
2445 with open(mf, "w"): |
2446 pass |
2446 pass |
2447 except EnvironmentError as err: |
2447 except OSError as err: |
2448 E5MessageBox.critical( |
2448 E5MessageBox.critical( |
2449 self.ui, |
2449 self.ui, |
2450 self.tr("Create Makefile"), |
2450 self.tr("Create Makefile"), |
2451 self.tr( |
2451 self.tr( |
2452 "<p>The makefile <b>{0}</b> could not" |
2452 "<p>The makefile <b>{0}</b> could not" |
2733 mf = os.path.join(self.ppath, Project.DefaultMakefile) |
2733 mf = os.path.join(self.ppath, Project.DefaultMakefile) |
2734 if not os.path.exists(mf): |
2734 if not os.path.exists(mf): |
2735 try: |
2735 try: |
2736 with open(mf, "w"): |
2736 with open(mf, "w"): |
2737 pass |
2737 pass |
2738 except EnvironmentError as err: |
2738 except OSError as err: |
2739 E5MessageBox.critical( |
2739 E5MessageBox.critical( |
2740 self.ui, |
2740 self.ui, |
2741 self.tr("Create Makefile"), |
2741 self.tr("Create Makefile"), |
2742 self.tr( |
2742 self.tr( |
2743 "<p>The makefile <b>{0}</b> could not" |
2743 "<p>The makefile <b>{0}</b> could not" |
2907 self.updateFileTypes() |
2907 self.updateFileTypes() |
2908 |
2908 |
2909 try: |
2909 try: |
2910 # create management directory if not present |
2910 # create management directory if not present |
2911 self.createProjectManagementDir() |
2911 self.createProjectManagementDir() |
2912 except EnvironmentError: |
2912 except OSError: |
2913 E5MessageBox.critical( |
2913 E5MessageBox.critical( |
2914 self.ui, |
2914 self.ui, |
2915 self.tr("Create project management directory"), |
2915 self.tr("Create project management directory"), |
2916 self.tr( |
2916 self.tr( |
2917 "<p>The project directory <b>{0}</b> is not" |
2917 "<p>The project directory <b>{0}</b> is not" |
5279 pkglistFile.write( |
5279 pkglistFile.write( |
5280 "\n".join([Utilities.fromNativeSeparators(f) |
5280 "\n".join([Utilities.fromNativeSeparators(f) |
5281 for f in lst])) |
5281 for f in lst])) |
5282 pkglistFile.write("\n") |
5282 pkglistFile.write("\n") |
5283 # ensure the file ends with an empty line |
5283 # ensure the file ends with an empty line |
5284 except IOError as why: |
5284 except OSError as why: |
5285 E5MessageBox.critical( |
5285 E5MessageBox.critical( |
5286 self.ui, |
5286 self.ui, |
5287 self.tr("Create Package List"), |
5287 self.tr("Create Package List"), |
5288 self.tr( |
5288 self.tr( |
5289 """<p>The file <b>PKGLIST</b> could not be created.</p>""" |
5289 """<p>The file <b>PKGLIST</b> could not be created.</p>""" |
5346 break |
5346 break |
5347 |
5347 |
5348 try: |
5348 try: |
5349 with open(pkglist, "r", encoding="utf-8") as pkglistFile: |
5349 with open(pkglist, "r", encoding="utf-8") as pkglistFile: |
5350 names = pkglistFile.read() |
5350 names = pkglistFile.read() |
5351 except IOError as why: |
5351 except OSError as why: |
5352 E5MessageBox.critical( |
5352 E5MessageBox.critical( |
5353 self.ui, |
5353 self.ui, |
5354 self.tr("Create Plugin Archive"), |
5354 self.tr("Create Plugin Archive"), |
5355 self.tr( |
5355 self.tr( |
5356 """<p>The file <b>{0}</b> could not be read.</p>""" |
5356 """<p>The file <b>{0}</b> could not be read.</p>""" |
5402 archive = os.path.join( |
5402 archive = os.path.join( |
5403 self.ppath, |
5403 self.ppath, |
5404 self.pdata["MAINSCRIPT"].replace(".py", ".zip")) |
5404 self.pdata["MAINSCRIPT"].replace(".py", ".zip")) |
5405 try: |
5405 try: |
5406 archiveFile = zipfile.ZipFile(archive, "w") |
5406 archiveFile = zipfile.ZipFile(archive, "w") |
5407 except IOError as why: |
5407 except OSError as why: |
5408 E5MessageBox.critical( |
5408 E5MessageBox.critical( |
5409 self.ui, |
5409 self.ui, |
5410 self.tr("Create Plugin Archive"), |
5410 self.tr("Create Plugin Archive"), |
5411 self.tr( |
5411 self.tr( |
5412 """<p>The eric6 plugin archive file <b>{0}</b>""" |
5412 """<p>The eric6 plugin archive file <b>{0}</b>""" |
5511 @return modified source (bytes), snapshot version string (string) |
5511 @return modified source (bytes), snapshot version string (string) |
5512 """ |
5512 """ |
5513 try: |
5513 try: |
5514 sourcelines, encoding = Utilities.readEncodedFile(filename) |
5514 sourcelines, encoding = Utilities.readEncodedFile(filename) |
5515 sourcelines = sourcelines.splitlines(True) |
5515 sourcelines = sourcelines.splitlines(True) |
5516 except (IOError, UnicodeError) as why: |
5516 except (OSError, UnicodeError) as why: |
5517 E5MessageBox.critical( |
5517 E5MessageBox.critical( |
5518 self.ui, |
5518 self.ui, |
5519 self.tr("Create Plugin Archive"), |
5519 self.tr("Create Plugin Archive"), |
5520 self.tr("""<p>The plugin file <b>{0}</b> could """ |
5520 self.tr("""<p>The plugin file <b>{0}</b> could """ |
5521 """not be read.</p>""" |
5521 """not be read.</p>""" |
5552 """ |
5552 """ |
5553 version = "0.0.0" |
5553 version = "0.0.0" |
5554 try: |
5554 try: |
5555 sourcelines = Utilities.readEncodedFile(filename)[0] |
5555 sourcelines = Utilities.readEncodedFile(filename)[0] |
5556 sourcelines = sourcelines.splitlines(True) |
5556 sourcelines = sourcelines.splitlines(True) |
5557 except (IOError, UnicodeError) as why: |
5557 except (OSError, UnicodeError) as why: |
5558 E5MessageBox.critical( |
5558 E5MessageBox.critical( |
5559 self.ui, |
5559 self.ui, |
5560 self.tr("Create Plugin Archive"), |
5560 self.tr("Create Plugin Archive"), |
5561 self.tr( |
5561 self.tr( |
5562 """<p>The plugin file <b>{0}</b> could """ |
5562 """<p>The plugin file <b>{0}</b> could """ |