1762 """ |
1762 """ |
1763 Public slot to delete a translation from the project directory. |
1763 Public slot to delete a translation from the project directory. |
1764 |
1764 |
1765 @param langFile the translation file to be removed (string) |
1765 @param langFile the translation file to be removed (string) |
1766 """ |
1766 """ |
1767 try: |
|
1768 from send2trash import send2trash as s2t # __IGNORE_WARNING_I10__ |
|
1769 except ImportError: |
|
1770 s2t = os.remove |
|
1771 |
|
1772 langFile = self.getRelativePath(langFile) |
1767 langFile = self.getRelativePath(langFile) |
1773 qmFile = self.__binaryTranslationFile(langFile) |
1768 qmFile = self.__binaryTranslationFile(langFile) |
1774 |
1769 |
1775 try: |
1770 try: |
1776 fn = os.path.join(self.ppath, langFile) |
1771 fn = os.path.join(self.ppath, langFile) |
1777 if os.path.exists(fn): |
1772 if os.path.exists(fn): |
1778 s2t(fn) |
1773 os.remove(fn) |
1779 except OSError as err: |
1774 except OSError as err: |
1780 EricMessageBox.critical( |
1775 EricMessageBox.critical( |
1781 self.ui, |
1776 self.ui, |
1782 self.tr("Delete translation"), |
1777 self.tr("Delete translation"), |
1783 self.tr( |
1778 self.tr( |
1799 os.path.basename(qmFile), |
1794 os.path.basename(qmFile), |
1800 ) |
1795 ) |
1801 ) |
1796 ) |
1802 fn = os.path.join(self.ppath, qmFile) |
1797 fn = os.path.join(self.ppath, qmFile) |
1803 if os.path.exists(fn): |
1798 if os.path.exists(fn): |
1804 s2t(fn) |
1799 os.remove(fn) |
1805 except OSError as err: |
1800 except OSError as err: |
1806 EricMessageBox.critical( |
1801 EricMessageBox.critical( |
1807 self.ui, |
1802 self.ui, |
1808 self.tr("Delete translation"), |
1803 self.tr("Delete translation"), |
1809 self.tr( |
1804 self.tr( |
2372 |
2367 |
2373 @param fn filename to be deleted from the project |
2368 @param fn filename to be deleted from the project |
2374 @return flag indicating success (boolean) |
2369 @return flag indicating success (boolean) |
2375 """ |
2370 """ |
2376 try: |
2371 try: |
2377 from send2trash import send2trash as s2t # __IGNORE_WARNING_I10__ |
2372 os.remove(os.path.join(self.ppath, fn)) |
2378 except ImportError: |
|
2379 s2t = os.remove |
|
2380 |
|
2381 try: |
|
2382 s2t(os.path.join(self.ppath, fn)) |
|
2383 path, ext = os.path.splitext(fn) |
2373 path, ext = os.path.splitext(fn) |
2384 if ext == ".ui": |
2374 if ext == ".ui": |
2385 fn2 = os.path.join(self.ppath, "{0}.h".format(fn)) |
2375 fn2 = os.path.join(self.ppath, "{0}.h".format(fn)) |
2386 if os.path.isfile(fn2): |
2376 if os.path.isfile(fn2): |
2387 s2t(fn2) |
2377 os.remove(fn2) |
2388 head, tail = os.path.split(path) |
2378 head, tail = os.path.split(path) |
2389 for ext in [".pyc", ".pyo"]: |
2379 for ext in [".pyc", ".pyo"]: |
2390 fn2 = os.path.join(self.ppath, path + ext) |
2380 fn2 = os.path.join(self.ppath, path + ext) |
2391 if os.path.isfile(fn2): |
2381 if os.path.isfile(fn2): |
2392 s2t(fn2) |
2382 os.remove(fn2) |
2393 pat = os.path.join( |
2383 pat = os.path.join( |
2394 self.ppath, head, "__pycache__", "{0}.*{1}".format(tail, ext) |
2384 self.ppath, head, "__pycache__", "{0}.*{1}".format(tail, ext) |
2395 ) |
2385 ) |
2396 for f in glob.glob(pat): |
2386 for f in glob.glob(pat): |
2397 s2t(f) |
2387 os.remove(f) |
2398 except OSError as err: |
2388 except OSError as err: |
2399 EricMessageBox.critical( |
2389 EricMessageBox.critical( |
2400 self.ui, |
2390 self.ui, |
2401 self.tr("Delete file"), |
2391 self.tr("Delete file"), |
2402 self.tr( |
2392 self.tr( |
2419 @return flag indicating success (boolean) |
2409 @return flag indicating success (boolean) |
2420 """ |
2410 """ |
2421 if not os.path.isabs(dn): |
2411 if not os.path.isabs(dn): |
2422 dn = os.path.join(self.ppath, dn) |
2412 dn = os.path.join(self.ppath, dn) |
2423 try: |
2413 try: |
2424 try: |
2414 shutil.rmtree(dn, True) |
2425 from send2trash import send2trash # __IGNORE_WARNING_I10__ |
|
2426 |
|
2427 send2trash(dn) |
|
2428 except ImportError: |
|
2429 shutil.rmtree(dn, True) |
|
2430 except OSError as err: |
2415 except OSError as err: |
2431 EricMessageBox.critical( |
2416 EricMessageBox.critical( |
2432 self.ui, |
2417 self.ui, |
2433 self.tr("Delete directory"), |
2418 self.tr("Delete directory"), |
2434 self.tr( |
2419 self.tr( |