Introduced optional argument to last_crx - return latest crx that is not newer than the passed date/time.
This commit is contained in:
parent
30c0b92979
commit
600ec933f4
|
@ -36,7 +36,7 @@ import shutil
|
||||||
import tarfile
|
import tarfile
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
|
import dateutil.parser
|
||||||
|
|
||||||
class Error(Exception):
|
class Error(Exception):
|
||||||
pass
|
pass
|
||||||
|
@ -177,13 +177,15 @@ def last_modified_http_date(path):
|
||||||
return httpdate(dateutil.parser.parse(last_modified_utc_date(path)))
|
return httpdate(dateutil.parser.parse(last_modified_utc_date(path)))
|
||||||
|
|
||||||
|
|
||||||
def last_crx(archivedir, extid):
|
def last_crx(archivedir, extid,date=None):
|
||||||
last_crx = ""
|
last_crx = ""
|
||||||
tar = os.path.join(archivedir, get_local_archive_dir(extid),
|
tar = os.path.join(archivedir, get_local_archive_dir(extid),
|
||||||
extid + ".tar")
|
extid + ".tar")
|
||||||
if os.path.exists(tar):
|
if os.path.exists(tar):
|
||||||
t = tarfile.open(tar, 'r')
|
t = tarfile.open(tar, 'r')
|
||||||
old_crxs = sorted([x.name for x in t.getmembers() if x.name.endswith(".crx") and x.size > 0])
|
old_crxs = sorted([x.name for x in t.getmembers() if x.name.endswith(".crx")
|
||||||
|
and x.size > 0
|
||||||
|
and (date is None or (dateutil.parser.parse(os.path.split(os.path.split(x.name)[0])[1]) <= date))])
|
||||||
t.close()
|
t.close()
|
||||||
if old_crxs != []:
|
if old_crxs != []:
|
||||||
last_crx = old_crxs[-1]
|
last_crx = old_crxs[-1]
|
||||||
|
|
Loading…
Reference in New Issue