From c8053725926596b5c1f4ff4b636d66b821e52bb5 Mon Sep 17 00:00:00 2001 From: numirias Date: Fri, 15 Jun 2018 23:28:52 +0200 Subject: [PATCH] Use time instead of datetime --- plasma/node.py | 8 ++++---- tests/test_layout.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plasma/node.py b/plasma/node.py index 0fec9a1..f7342e0 100644 --- a/plasma/node.py +++ b/plasma/node.py @@ -1,5 +1,5 @@ from collections import namedtuple -from datetime import datetime +import time from math import isclose import sys @@ -70,7 +70,7 @@ def __init__(self, payload=None, x=None, y=None, width=None, height=None): self._height = height self._size = None self.children = [] - self.last_accessed = datetime.min + self.last_accessed = 0 self.parent = None self.restorables = {} @@ -406,7 +406,7 @@ def flexible(self): return all((any(gc.flexible for gc in c) or c.is_leaf) for c in self) def access(self): - self.last_accessed = datetime.now() + self.last_accessed = time.time() try: self.parent.access() except AttributeError: @@ -460,7 +460,7 @@ def close_neighbor(self, direction): if not nodes: return None most_recent = max(nodes, key=lambda n: n.last_accessed) - if most_recent.last_accessed > datetime.min: + if most_recent.last_accessed > 0: return most_recent if direction in [UP, DOWN]: match = lambda n: n.x <= self.x_center <= n.x_end diff --git a/tests/test_layout.py b/tests/test_layout.py index 03bf2b2..f1975f8 100644 --- a/tests/test_layout.py +++ b/tests/test_layout.py @@ -1,7 +1,7 @@ -from datetime import datetime from pathlib import Path from pytest import fixture, mark import sys +import time from plasma import Plasma from plasma.node import Node @@ -74,7 +74,7 @@ def test_access(self, root): layout = Plasma() layout.root = root layout.add('a') - now = datetime.now() + now = time.time() assert layout.root.find_payload('a').last_accessed < now layout.focus('a') assert layout.root.find_payload('a').last_accessed > now