diff --git a/linkcheck/fileutil.py b/linkcheck/fileutil.py index 5d6e510c..c21286b2 100644 --- a/linkcheck/fileutil.py +++ b/linkcheck/fileutil.py @@ -138,16 +138,10 @@ class Buffer (object): return data -@memoized -def get_stat(filename): - """Return stat(2) data for given filename. Kan raise os.error""" - return os.stat(filename) - - def get_mtime (filename): """Return modification time of filename or zero on errors.""" try: - return get_stat(filename)[stat.ST_MTIME] + return os.path.getmtime(filename) except os.error: return 0 @@ -155,7 +149,7 @@ def get_mtime (filename): def get_size (filename): """Return file size in Bytes, or -1 on error.""" try: - return get_stat(filename)[stat.ST_SIZE] + return os.path.getsize(filename) except os.error: return -1 @@ -274,7 +268,7 @@ def is_readable(filename): def is_accessable_by_others(filename): """Check if file is group or world accessable.""" - mode = get_stat(filename)[stat.ST_MODE] + mode = os.stat(filename)[stat.ST_MODE] return mode & (stat.S_IRWXG | stat.S_IRWXO) diff --git a/linkcheck/strformat.py b/linkcheck/strformat.py index 3a619604..28b78e74 100644 --- a/linkcheck/strformat.py +++ b/linkcheck/strformat.py @@ -34,6 +34,7 @@ import os import math import time import urlparse +import locale import pydoc from . import i18n @@ -184,18 +185,18 @@ def strsize (b): if b < 0: raise ValueError("Invalid negative byte number") if b < 1024: - return u"%dB" % b + return u"%sB" % locale.format("%d", b, True) if b < 1024 * 10: - return u"%dKB" % (b // 1024) + return u"%sKB" % locale.format("%d", (b // 1024), True) if b < 1024 * 1024: - return u"%.2fKB" % (float(b) / 1024) + return u"%sKB" % locale.format("%.2f", (float(b) / 1024), True) if b < 1024 * 1024 * 10: - return u"%.2fMB" % (float(b) / (1024*1024)) + return u"%sMB" % locale.format("%.2f", (float(b) / (1024*1024)), True) if b < 1024 * 1024 * 1024: - return u"%.1fMB" % (float(b) / (1024*1024)) + return u"%sMB" % locale.format("%.1f", (float(b) / (1024*1024)), True) if b < 1024 * 1024 * 1024 * 10: - return u"%.2fGB" % (float(b) / (1024*1024*1024)) - return u"%.1fGB" % (float(b) / (1024*1024*1024)) + return u"%sGB" % locale.format("%.2f", (float(b) / (1024*1024*1024)), True) + return u"%sGB" % locale.format("%.1f", (float(b) / (1024*1024*1024)), True) def strtime (t):