Line
Link Here
|
0 |
-- portage/_sets/dbapi.py |
0 |
++ portage/_sets/dbapi.py |
Lines 355-360
Link Here
|
355 |
|
355 |
|
356 |
singleBuilder = classmethod(singleBuilder) |
356 |
singleBuilder = classmethod(singleBuilder) |
357 |
|
357 |
|
|
|
358 |
class DateSet(EverythingSet): |
359 |
_operations = ["merge", "unmerge"] |
360 |
|
361 |
def __init__(self, vardb, date, mode="older"): |
362 |
super(DateSet, self).__init__(vardb) |
363 |
self._mode = mode |
364 |
self._date = date |
365 |
|
366 |
def _filter(self, atom): |
367 |
|
368 |
cpv = self._db.match(atom)[0] |
369 |
path = self._db.getpath(cpv, filename="COUNTER") |
370 |
date = os.stat(path).st_mtime |
371 |
# Make sure inequality is _strict_ to exclude tested package |
372 |
if ((self._mode == "older" and date < self._date) \ |
373 |
or (self._mode == "newer" and date > self._date)): |
374 |
return True |
375 |
else: |
376 |
return False |
377 |
|
378 |
def singleBuilder(cls, options, settings, trees): |
379 |
vardbapi = trees["vartree"].dbapi |
380 |
mode = options.get("mode", "older") |
381 |
if str(mode).lower() not in ["newer", "older"]: |
382 |
raise SetConfigError(_("invalid 'mode' value %s (use either 'newer' or 'older')") % mode) |
383 |
package = options.get("package") |
384 |
if package is not None: |
385 |
format = "package" |
386 |
else: |
387 |
filestamp = options.get("filestamp") |
388 |
if filestamp is not None: |
389 |
format = "filestamp" |
390 |
else: |
391 |
seconds = options.get("seconds") |
392 |
if seconds is not None: |
393 |
format = "seconds" |
394 |
else: |
395 |
dateopt = options.get("date") |
396 |
if dateopt is not None: |
397 |
format = "date" |
398 |
else: |
399 |
raise SetConfigError(_("none of these options specified: 'package', 'filestamp', 'seconds', 'date'")) |
400 |
if (format == "package"): |
401 |
try: |
402 |
cpv = vardbapi.match(package)[0] |
403 |
path = vardbapi.getpath(cpv, filename="COUNTER") |
404 |
date = os.stat(path).st_mtime |
405 |
except ValueError as e: |
406 |
raise SetConfigError(_("cannot determine installation date of package %s") % package) |
407 |
elif (format == "filestamp"): |
408 |
try: |
409 |
date = os.stat(filestamp).st_mtime |
410 |
except ValueError as e: |
411 |
raise SetConfigError(_("cannot determine 'filestamp' of '%s'") % s) |
412 |
elif (format == "seconds"): |
413 |
# Do *not* test for integer: |
414 |
# Modern filesystems support fractional seconds |
415 |
date = seconds |
416 |
else: |
417 |
try: |
418 |
dateformat = options.get("dateformat", "%x %X") |
419 |
date = time.mktime(time.strptime(dateopt, dateformat)) |
420 |
except ValueError as e: |
421 |
raise SetConfigError(_("'date=%s' does not match 'dateformat=%s'") % (dateopt, dateformat)) |
422 |
return DateSet(vardb=vardbapi, date=date, mode=mode) |
423 |
|
424 |
singleBuilder = classmethod(singleBuilder) |
425 |
|
358 |
class RebuiltBinaries(EverythingSet): |
426 |
class RebuiltBinaries(EverythingSet): |
359 |
_operations = ('merge',) |
427 |
_operations = ('merge',) |
360 |
_aux_keys = ('BUILD_TIME',) |
428 |
_aux_keys = ('BUILD_TIME',) |