Line
Link Here
|
0 |
-- /gentoo32/usr/lib/portage/pym/portage/_sets/dbapi.py/gentoo32/usr/lib/portage/pym/portage/_sets/dbapi.py |
0 |
++ /gentoo32/usr/lib/portage/pym/portage/_sets/dbapi.py/usr/lib/portage/pym/portage/_sets/dbapi.py |
Lines 326-331
Link Here
|
326 |
|
326 |
|
327 |
class AgeSet(EverythingSet): |
327 |
class AgeSet(EverythingSet): |
328 |
_operations = ["merge", "unmerge"] |
328 |
_operations = ["merge", "unmerge"] |
|
|
329 |
_aux_keys = ('BUILD_TIME',) |
329 |
|
330 |
|
330 |
def __init__(self, vardb, mode="older", age=7): |
331 |
def __init__(self, vardb, mode="older", age=7): |
331 |
super(AgeSet, self).__init__(vardb) |
332 |
super(AgeSet, self).__init__(vardb) |
Lines 335-342
Link Here
|
335 |
def _filter(self, atom): |
336 |
def _filter(self, atom): |
336 |
|
337 |
|
337 |
cpv = self._db.match(atom)[0] |
338 |
cpv = self._db.match(atom)[0] |
338 |
path = self._db.getpath(cpv, filename="COUNTER") |
339 |
try: |
339 |
age = (time.time() - os.stat(path).st_mtime) / (3600 * 24) |
340 |
date, = self._db.aux_get(cpv, self._aux_keys) |
|
|
341 |
date = int(date) |
342 |
except (KeyError, ValueError): |
343 |
return bool(self._mode == "older") |
344 |
age = (time.time() - date) / (3600 * 24) |
340 |
if ((self._mode == "older" and age <= self._age) \ |
345 |
if ((self._mode == "older" and age <= self._age) \ |
341 |
or (self._mode == "newer" and age >= self._age)): |
346 |
or (self._mode == "newer" and age >= self._age)): |
342 |
return False |
347 |
return False |
Lines 357-362
Link Here
|
357 |
|
362 |
|
358 |
class DateSet(EverythingSet): |
363 |
class DateSet(EverythingSet): |
359 |
_operations = ["merge", "unmerge"] |
364 |
_operations = ["merge", "unmerge"] |
|
|
365 |
_aux_keys = ('BUILD_TIME',) |
360 |
|
366 |
|
361 |
def __init__(self, vardb, date, mode="older"): |
367 |
def __init__(self, vardb, date, mode="older"): |
362 |
super(DateSet, self).__init__(vardb) |
368 |
super(DateSet, self).__init__(vardb) |
Lines 366-373
Link Here
|
366 |
def _filter(self, atom): |
372 |
def _filter(self, atom): |
367 |
|
373 |
|
368 |
cpv = self._db.match(atom)[0] |
374 |
cpv = self._db.match(atom)[0] |
369 |
path = self._db.getpath(cpv, filename="COUNTER") |
375 |
try: |
370 |
date = os.stat(path).st_mtime |
376 |
date, = self._db.aux_get(cpv, self._aux_keys) |
|
|
377 |
except KeyError: |
378 |
return bool(self._mode == "older") |
371 |
# Make sure inequality is _strict_ to exclude tested package |
379 |
# Make sure inequality is _strict_ to exclude tested package |
372 |
if ((self._mode == "older" and date < self._date) \ |
380 |
if ((self._mode == "older" and date < self._date) \ |
373 |
or (self._mode == "newer" and date > self._date)): |
381 |
or (self._mode == "newer" and date > self._date)): |
Lines 402-426
Link Here
|
402 |
package = options.get("package") |
410 |
package = options.get("package") |
403 |
try: |
411 |
try: |
404 |
cpv = vardbapi.match(package)[0] |
412 |
cpv = vardbapi.match(package)[0] |
405 |
path = vardbapi.getpath(cpv, filename="COUNTER") |
413 |
date, = vardbapi.aux_get(cpv, ('BUILD_TIME',)) |
406 |
date = os.stat(path).st_mtime |
414 |
date = int(date) |
407 |
except ValueError: |
415 |
except (KeyError, ValueError): |
408 |
raise SetConfigError(_("cannot determine installation date of package %s") % package) |
416 |
raise SetConfigError(_("cannot determine installation date of package %s") % package) |
409 |
elif (format == "filestamp"): |
417 |
elif (format == "filestamp"): |
410 |
filestamp = options.get("filestamp") |
418 |
filestamp = options.get("filestamp") |
411 |
try: |
419 |
try: |
412 |
date = os.stat(filestamp).st_mtime |
420 |
date = int(os.stat(filestamp).st_mtime) |
413 |
except OSError: |
421 |
except (OSError, ValueError): |
414 |
raise SetConfigError(_("cannot determine 'filestamp' of '%s'") % filestamp) |
422 |
raise SetConfigError(_("cannot determine 'filestamp' of '%s'") % filestamp) |
415 |
elif (format == "seconds"): |
423 |
elif (format == "seconds"): |
416 |
# Do *not* test for integer: |
424 |
try: |
417 |
# Modern filesystems support fractional seconds |
425 |
date = int(options.get("seconds")) |
418 |
date = options.get("seconds") |
426 |
except ValueError: |
|
|
427 |
raise SetConfigError(_("option 'seconds' must be an integer")) |
419 |
else: |
428 |
else: |
420 |
dateopt = options.get("date") |
429 |
dateopt = options.get("date") |
421 |
try: |
430 |
try: |
422 |
dateformat = options.get("dateformat", "%x %X") |
431 |
dateformat = options.get("dateformat", "%x %X") |
423 |
date = time.mktime(time.strptime(dateopt, dateformat)) |
432 |
date = int(time.mktime(time.strptime(dateopt, dateformat))) |
424 |
except ValueError: |
433 |
except ValueError: |
425 |
raise SetConfigError(_("'date=%s' does not match 'dateformat=%s'") % (dateopt, dateformat)) |
434 |
raise SetConfigError(_("'date=%s' does not match 'dateformat=%s'") % (dateopt, dateformat)) |
426 |
return DateSet(vardb=vardbapi, date=date, mode=mode) |
435 |
return DateSet(vardb=vardbapi, date=date, mode=mode) |