You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@community.apache.org by se...@apache.org on 2015/11/04 18:11:31 UTC

svn commit: r1712592 - /comdev/reporter.apache.org/trunk/scripts/urlutils.py

Author: sebb
Date: Wed Nov  4 17:11:30 2015
New Revision: 1712592

URL: http://svn.apache.org/viewvc?rev=1712592&view=rev
Log:
Factor out touchfile method for general use

Modified:
    comdev/reporter.apache.org/trunk/scripts/urlutils.py

Modified: comdev/reporter.apache.org/trunk/scripts/urlutils.py
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/scripts/urlutils.py?rev=1712592&r1=1712591&r2=1712592&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/scripts/urlutils.py (original)
+++ comdev/reporter.apache.org/trunk/scripts/urlutils.py Wed Nov  4 17:11:30 2015
@@ -24,6 +24,12 @@ import calendar
 # time format used in Last-Modified/If-Modified-Since HTTP headers
 _HTTP_TIME_FORMAT = '%a, %d %b %Y %H:%M:%S GMT'
 
+def touchFile(f, t):
+    if _PY3:
+        os.utime(f, times=(t, t))
+    else:
+        os.utime(f, (t, t))
+
 def mod_date(t):
     """
         get file mod date in suitable format for If-Modified-Since
@@ -168,10 +174,7 @@ class UrlCache(object):
                 with open(tmpFile,'wb') as f:
                     shutil.copyfileobj(response, f)
                 # store the last mod time as the time of the file
-                if _PY3:
-                    os.utime(tmpFile, times=(lastModT, lastModT))
-                else:
-                    os.utime(tmpFile, (lastModT, lastModT))
+                touchFile(tmpFile, lastModT)
                 os.rename(tmpFile, target) # seems to preserve file mod time
                 if lastMod:
                     if fileTime > 0: