Set correct mtime of zip file
Since we are writing the zip file with python, the original mdate, on which is_zip_uptodate() relies gets lost. Therefore overwrite it with value of "Last-Modified" HTTP header
This commit is contained in:
@@ -24,6 +24,7 @@ import datetime
|
|||||||
import zipfile
|
import zipfile
|
||||||
import shlex
|
import shlex
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import email.utils
|
||||||
|
|
||||||
import pywikibot
|
import pywikibot
|
||||||
|
|
||||||
@@ -167,6 +168,15 @@ class EuroExangeBot( pywikibot.bot.BaseBot ):
|
|||||||
|
|
||||||
shutil.copyfileobj(response, out_file)
|
shutil.copyfileobj(response, out_file)
|
||||||
|
|
||||||
|
# Extract original change date from http header
|
||||||
|
# We need to set it later, since we write a new file
|
||||||
|
mdate = email.utils.parsedate_to_datetime(
|
||||||
|
response.info()["Last-Modified"])
|
||||||
|
|
||||||
|
# Set ctime to value from http header
|
||||||
|
os.utime( os.path.join(self.wdir, type(self).zip_file),
|
||||||
|
(datetime.datetime.now().timestamp(), mdate.timestamp()) )
|
||||||
|
|
||||||
def extract_csv( self ):
|
def extract_csv( self ):
|
||||||
"""
|
"""
|
||||||
Extract csv file from zip archive
|
Extract csv file from zip archive
|
||||||
|
|||||||
Reference in New Issue
Block a user