mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-20 06:10:59 +00:00
strduration helper
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@1140 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
496b4bd8df
commit
45620a8453
7 changed files with 31 additions and 60 deletions
|
|
@ -16,7 +16,7 @@
|
|||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
import time, csv
|
||||
from linkcheck.log import strtime
|
||||
from linkcheck.log import strtime, strduration
|
||||
from StandardLogger import StandardLogger
|
||||
from Logger import Logger
|
||||
from linkcheck import Config, i18n
|
||||
|
|
@ -82,15 +82,8 @@ class CSVLogger (StandardLogger):
|
|||
self.stoptime = time.time()
|
||||
if self.has_field("outro"):
|
||||
duration = self.stoptime - self.starttime
|
||||
name = i18n._("seconds")
|
||||
self.fd.write("# "+i18n._("Stopped checking at %s") % strtime(self.stoptime))
|
||||
if duration > 60:
|
||||
duration = duration / 60
|
||||
name = i18n._("minutes")
|
||||
if duration > 60:
|
||||
duration = duration / 60
|
||||
name = i18n._("hours")
|
||||
self.fd.write(" (%.3f %s)%s" % (duration, name, self.lineterminator))
|
||||
self.fd.write("# "+i18n._("Stopped checking at %s (%s)%s")%\
|
||||
(strtime(self.stoptime), strduration(duration), self.lineterminator))
|
||||
self.fd.flush()
|
||||
self.fd.close()
|
||||
self.fd = None
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
import time
|
||||
from linkcheck import Config, i18n
|
||||
from linkcheck.log import strtime
|
||||
from linkcheck.log import strtime, strduration
|
||||
from StandardLogger import StandardLogger
|
||||
from Logger import Logger
|
||||
|
||||
|
|
@ -93,15 +93,7 @@ class GMLLogger (StandardLogger):
|
|||
if self.has_field("outro"):
|
||||
self.stoptime = time.time()
|
||||
duration = self.stoptime - self.starttime
|
||||
name = i18n._("seconds")
|
||||
self.fd.write("# "+i18n._("Stopped checking at %s") % \
|
||||
strtime(self.stoptime))
|
||||
if duration > 60:
|
||||
duration = duration / 60
|
||||
name = i18n._("minutes")
|
||||
if duration > 60:
|
||||
duration = duration / 60
|
||||
name = i18n._("hours")
|
||||
self.fd.write(" (%.3f %s)\n" % (duration, name))
|
||||
self.fd.write("# "+i18n._("Stopped checking at %s (%s)\n")%\
|
||||
(strtime(self.stoptime), strduration(duration)))
|
||||
self.fd.flush()
|
||||
self.fd = None
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
from StandardLogger import StandardLogger
|
||||
from Logger import Logger
|
||||
from linkcheck.log import strtime
|
||||
from linkcheck.log import strtime, strduration
|
||||
from linkcheck import StringUtil, i18n, Config
|
||||
import time
|
||||
|
||||
|
|
@ -157,15 +157,8 @@ class HtmlLogger (StandardLogger):
|
|||
self.fd.write(i18n._(" found")+"\n<br>")
|
||||
self.stoptime = time.time()
|
||||
duration = self.stoptime - self.starttime
|
||||
name = i18n._("seconds")
|
||||
self.fd.write(i18n._("Stopped checking at %s") % strtime(self.stoptime))
|
||||
if duration > 60:
|
||||
duration = duration / 60
|
||||
name = i18n._("minutes")
|
||||
if duration > 60:
|
||||
duration = duration / 60
|
||||
name = i18n._("hours")
|
||||
self.fd.write(" (%.3f %s)\n" % (duration, name))
|
||||
self.fd.write(i18n._("Stopped checking at %s (%s)\n")%\
|
||||
(strtime(self.stoptime), strduration(duration)))
|
||||
self.fd.write("</blockquote><br><hr noshade size=\"1\"><small>"+
|
||||
Config.HtmlAppInfo+"<br>")
|
||||
self.fd.write(i18n._("Get the newest version at %s\n") %\
|
||||
|
|
|
|||
|
|
@ -76,15 +76,7 @@ class SQLLogger (StandardLogger):
|
|||
if self.has_field("outro"):
|
||||
self.stoptime = time.time()
|
||||
duration = self.stoptime - self.starttime
|
||||
name = i18n._("seconds")
|
||||
self.fd.write("-- "+i18n._("Stopped checking at %s") % \
|
||||
strtime(self.stoptime))
|
||||
if duration > 60:
|
||||
duration = duration / 60
|
||||
name = i18n._("minutes")
|
||||
if duration > 60:
|
||||
duration = duration / 60
|
||||
name = i18n._("hours")
|
||||
self.fd.write(" (%.3f %s)\n" % (duration, name))
|
||||
self.fd.write("-- "+i18n._("Stopped checking at %s (%s)\n")%\
|
||||
(strtime(self.stoptime), strduration(duration)))
|
||||
self.fd.flush()
|
||||
self.fd = None
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
import sys, time
|
||||
from linkcheck import Config, i18n
|
||||
from Logger import Logger
|
||||
from linkcheck.log import strtime
|
||||
from linkcheck.log import strtime, strduration
|
||||
from linkcheck import StringUtil
|
||||
|
||||
class StandardLogger (Logger):
|
||||
|
|
@ -154,14 +154,7 @@ __init__(self, **args)
|
|||
self.fd.write(i18n._(" found\n"))
|
||||
self.stoptime = time.time()
|
||||
duration = self.stoptime - self.starttime
|
||||
name = i18n._("seconds")
|
||||
self.fd.write(i18n._("Stopped checking at %s") % strtime(self.stoptime))
|
||||
if duration > 60:
|
||||
duration = duration / 60
|
||||
name = i18n._("minutes")
|
||||
if duration > 60:
|
||||
duration = duration / 60
|
||||
name = i18n._("hours")
|
||||
self.fd.write(" (%.3f %s)\n" % (duration, name))
|
||||
self.fd.write(i18n._("Stopped checking at %s (%s)\n") % \
|
||||
(strtime(self.stoptime), strduration(duration)))
|
||||
self.fd.flush()
|
||||
self.fd = None
|
||||
|
|
|
|||
|
|
@ -104,16 +104,9 @@ class XMLLogger (StandardLogger):
|
|||
if self.has_field("outro"):
|
||||
self.stoptime = time.time()
|
||||
duration = self.stoptime - self.starttime
|
||||
name = i18n._("seconds")
|
||||
self.fd.write("<!-- ")
|
||||
self.fd.write(i18n._("Stopped checking at %s") % strtime(self.stoptime))
|
||||
if duration > 60:
|
||||
duration = duration / 60
|
||||
name = i18n._("minutes")
|
||||
if duration > 60:
|
||||
duration = duration / 60
|
||||
name = i18n._("hours")
|
||||
self.fd.write(" (%.3f %s)\n" % (duration, name))
|
||||
self.fd.write(i18n._("Stopped checking at %s (%s)\n")%\
|
||||
(strtime(self.stoptime), strduration(duration)))
|
||||
self.fd.write("-->")
|
||||
self.fd.flush()
|
||||
self.fd = None
|
||||
|
|
|
|||
|
|
@ -17,12 +17,26 @@
|
|||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
import time
|
||||
from linkcheck import i18n
|
||||
|
||||
def strtime (t):
|
||||
"""return ISO 8601 formatted time"""
|
||||
return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(t)) + \
|
||||
strtimezone()
|
||||
|
||||
|
||||
def strduration (duration):
|
||||
"""return string formatted time duration"""
|
||||
name = i18n._("seconds")
|
||||
if duration > 60:
|
||||
duration = duration / 60
|
||||
name = i18n._("minutes")
|
||||
if duration > 60:
|
||||
duration = duration / 60
|
||||
name = i18n._("hours")
|
||||
return " %.3f %s"%(duration, name)
|
||||
|
||||
|
||||
def strtimezone ():
|
||||
"""return timezone info, %z on some platforms, but not supported on all"""
|
||||
if time.daylight:
|
||||
|
|
@ -31,6 +45,7 @@ def strtimezone ():
|
|||
zone = time.timezone
|
||||
return "%+04d" % int(-zone/3600)
|
||||
|
||||
|
||||
from StandardLogger import StandardLogger
|
||||
from HtmlLogger import HtmlLogger
|
||||
from ColoredLogger import ColoredLogger
|
||||
|
|
|
|||
Loading…
Reference in a new issue