http://www.mediawiki.org/wiki/Special:Code/MediaWiki/99435

Revision: 99435
Author:   ariel
Date:     2011-10-10 21:47:20 +0000 (Mon, 10 Oct 2011)
Log Message:
-----------
function for file size and date

Modified Paths:
--------------
    branches/ariel/xmldumps-backup/WikiDump.py

Modified: branches/ariel/xmldumps-backup/WikiDump.py
===================================================================
--- branches/ariel/xmldumps-backup/WikiDump.py  2011-10-10 21:36:52 UTC (rev 
99434)
+++ branches/ariel/xmldumps-backup/WikiDump.py  2011-10-10 21:47:20 UTC (rev 
99435)
@@ -87,6 +87,17 @@
                else:
                        return FileUtils._prettySize(size / 1024.0, quanta[1:])
 
+       def fileInfo(path):
+               """Return a tuple of date/time and size of a file, or None, 
None"""
+               try:
+                       timestamp = time.gmtime(os.stat(path).st_mtime)
+                       timestamp = time.strftime("%Y-%m-%d %H:%M:%S",timestamp)
+                       size = os.path.getsize(path)
+                       return (timestamp, size)
+               except:
+                       raise
+                       return(None, None)
+
        fileAge = staticmethod(fileAge)
        atomicCreate = staticmethod(atomicCreate)
        writeFile = staticmethod(writeFile)
@@ -96,6 +107,7 @@
        relativePath = staticmethod(relativePath)
        prettySize = staticmethod(prettySize)
        _prettySize = staticmethod(_prettySize)
+       fileInfo = staticmethod(fileInfo)
 
 class TimeUtils(object):
 


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to