Fix usage of posixpath; should be os.path for os independence (#650)

Fixes #10740
This commit is contained in:
Paul Culley 2018-09-03 20:20:34 -05:00 committed by Sam Manzi
parent 2aec83f057
commit 224748eb96
5 changed files with 10 additions and 11 deletions

View File

@ -38,7 +38,6 @@ import os
import time import time
import datetime import datetime
from io import StringIO from io import StringIO
import posixpath
import gc 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(): for media in self.dbstate.db.iter_media():
fullname = media_path_full(self.dbstate.db, media.get_path()) fullname = media_path_full(self.dbstate.db, media.get_path())
try: try:
fbytes += posixpath.getsize(fullname) fbytes += os.path.getsize(fullname)
length = len(str(fbytes)) length = len(str(fbytes))
if fbytes <= 999999: if fbytes <= 999999:
mbytes = "< 1" mbytes = "< 1"

View File

@ -21,7 +21,7 @@
# Python modules # Python modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
import posixpath import os
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -81,7 +81,7 @@ class StatsGramplet(Gramplet):
for media in database.iter_media(): for media in database.iter_media():
fullname = media_path_full(database, media.get_path()) fullname = media_path_full(database, media.get_path())
try: try:
bytes += posixpath.getsize(fullname) bytes += os.path.getsize(fullname)
length = len(str(bytes)) length = len(str(bytes))
if bytes <= 999999: if bytes <= 999999:
mbytes = _("less than 1") mbytes = _("less than 1")

View File

@ -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.lib import Person
from gramps.gen.datehandler import get_date from gramps.gen.datehandler import get_date
import posixpath import os
from collections import defaultdict from collections import defaultdict
from gramps.gen.const import GRAMPS_LOCALE as glocale from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext _ = glocale.translation.sgettext
@ -389,7 +389,7 @@ def run(database, document, filter_name, *args, **kwargs):
for photo in database.iter_media(): for photo in database.iter_media():
fullname = media_path_full(database, photo.get_path()) fullname = media_path_full(database, photo.get_path())
try: try:
posixpath.getsize(fullname) os.path.getsize(fullname)
except: except:
stab.row(fullname) stab.row(fullname)
matches += 1 matches += 1
@ -399,7 +399,7 @@ def run(database, document, filter_name, *args, **kwargs):
for photo in database.iter_media(): for photo in database.iter_media():
fullname = media_path_full(database, photo.get_path()) fullname = media_path_full(database, photo.get_path())
try: try:
bytes = posixpath.getsize(fullname) bytes = os.path.getsize(fullname)
stab.row(fullname, str(bytes)) stab.row(fullname, str(bytes))
matches += 1 matches += 1
except: except:

View File

@ -30,7 +30,7 @@ Reports/Text Reports/Database Summary Report.
# standard python modules # standard python modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
import posixpath import os
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -233,7 +233,7 @@ class SummaryReport(Report):
for media_id in self.__db.get_media_handles(): for media_id in self.__db.get_media_handles():
media = self.__db.get_media_from_handle(media_id) media = self.__db.get_media_from_handle(media_id)
try: try:
size_in_bytes += posixpath.getsize( size_in_bytes += os.path.getsize(
media_path_full(self.__db, media.get_path())) media_path_full(self.__db, media.get_path()))
length = len(str(size_in_bytes)) length = len(str(size_in_bytes))
if size_in_bytes <= 999999: if size_in_bytes <= 999999:

View File

@ -74,7 +74,7 @@ class StatisticsPage(BasePage):
for this report for this report
@param: title -- Is the title of the web page @param: title -- Is the title of the web page
""" """
import posixpath import os
BasePage.__init__(self, report, title) BasePage.__init__(self, report, title)
self.bibli = Bibliography() self.bibli = Bibliography()
self.uplink = False self.uplink = False
@ -99,7 +99,7 @@ class StatisticsPage(BasePage):
total_media += 1 total_media += 1
fullname = media_path_full(report.database, media.get_path()) fullname = media_path_full(report.database, media.get_path())
try: try:
chars += posixpath.getsize(fullname) chars += os.path.getsize(fullname)
length = len(str(chars)) length = len(str(chars))
if chars <= 999999: if chars <= 999999:
mbytes = _("less than 1") mbytes = _("less than 1")