From 224748eb9643d10d1c5ee7056d33cc5e56eb8553 Mon Sep 17 00:00:00 2001 From: Paul Culley Date: Mon, 3 Sep 2018 20:20:34 -0500 Subject: [PATCH] Fix usage of posixpath; should be os.path for os independence (#650) Fixes #10740 --- gramps/gui/viewmanager.py | 3 +-- gramps/plugins/gramplet/statsgramplet.py | 4 ++-- gramps/plugins/quickview/filterbyname.py | 6 +++--- gramps/plugins/textreport/summary.py | 4 ++-- gramps/plugins/webreport/statistics.py | 4 ++-- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/gramps/gui/viewmanager.py b/gramps/gui/viewmanager.py index b314fa6e9..3f3c9cdc2 100644 --- a/gramps/gui/viewmanager.py +++ b/gramps/gui/viewmanager.py @@ -38,7 +38,6 @@ import os import time import datetime from io import StringIO -import posixpath import gc #------------------------------------------------------------------------- @@ -1912,7 +1911,7 @@ class QuickBackup(ManagedWindow): # TODO move this class into its own module for media in self.dbstate.db.iter_media(): fullname = media_path_full(self.dbstate.db, media.get_path()) try: - fbytes += posixpath.getsize(fullname) + fbytes += os.path.getsize(fullname) length = len(str(fbytes)) if fbytes <= 999999: mbytes = "< 1" diff --git a/gramps/plugins/gramplet/statsgramplet.py b/gramps/plugins/gramplet/statsgramplet.py index 7c6bd7b9d..ff1f4434a 100644 --- a/gramps/plugins/gramplet/statsgramplet.py +++ b/gramps/plugins/gramplet/statsgramplet.py @@ -21,7 +21,7 @@ # Python modules # #------------------------------------------------------------------------ -import posixpath +import os #------------------------------------------------------------------------ # @@ -81,7 +81,7 @@ class StatsGramplet(Gramplet): for media in database.iter_media(): fullname = media_path_full(database, media.get_path()) try: - bytes += posixpath.getsize(fullname) + bytes += os.path.getsize(fullname) length = len(str(bytes)) if bytes <= 999999: mbytes = _("less than 1") diff --git a/gramps/plugins/quickview/filterbyname.py b/gramps/plugins/quickview/filterbyname.py index 4e9a94653..ae3c49869 100644 --- a/gramps/plugins/quickview/filterbyname.py +++ b/gramps/plugins/quickview/filterbyname.py @@ -32,7 +32,7 @@ from gramps.gui.plug.quick import run_quick_report_by_name_direct from gramps.gen.lib import Person from gramps.gen.datehandler import get_date -import posixpath +import os from collections import defaultdict from gramps.gen.const import GRAMPS_LOCALE as glocale _ = glocale.translation.sgettext @@ -389,7 +389,7 @@ def run(database, document, filter_name, *args, **kwargs): for photo in database.iter_media(): fullname = media_path_full(database, photo.get_path()) try: - posixpath.getsize(fullname) + os.path.getsize(fullname) except: stab.row(fullname) matches += 1 @@ -399,7 +399,7 @@ def run(database, document, filter_name, *args, **kwargs): for photo in database.iter_media(): fullname = media_path_full(database, photo.get_path()) try: - bytes = posixpath.getsize(fullname) + bytes = os.path.getsize(fullname) stab.row(fullname, str(bytes)) matches += 1 except: diff --git a/gramps/plugins/textreport/summary.py b/gramps/plugins/textreport/summary.py index dd8a7b3cb..5d164a7db 100644 --- a/gramps/plugins/textreport/summary.py +++ b/gramps/plugins/textreport/summary.py @@ -30,7 +30,7 @@ Reports/Text Reports/Database Summary Report. # standard python modules # #------------------------------------------------------------------------ -import posixpath +import os #------------------------------------------------------------------------ # @@ -233,7 +233,7 @@ class SummaryReport(Report): for media_id in self.__db.get_media_handles(): media = self.__db.get_media_from_handle(media_id) try: - size_in_bytes += posixpath.getsize( + size_in_bytes += os.path.getsize( media_path_full(self.__db, media.get_path())) length = len(str(size_in_bytes)) if size_in_bytes <= 999999: diff --git a/gramps/plugins/webreport/statistics.py b/gramps/plugins/webreport/statistics.py index 134572d93..ff7a10650 100644 --- a/gramps/plugins/webreport/statistics.py +++ b/gramps/plugins/webreport/statistics.py @@ -74,7 +74,7 @@ class StatisticsPage(BasePage): for this report @param: title -- Is the title of the web page """ - import posixpath + import os BasePage.__init__(self, report, title) self.bibli = Bibliography() self.uplink = False @@ -99,7 +99,7 @@ class StatisticsPage(BasePage): total_media += 1 fullname = media_path_full(report.database, media.get_path()) try: - chars += posixpath.getsize(fullname) + chars += os.path.getsize(fullname) length = len(str(chars)) if chars <= 999999: mbytes = _("less than 1")