diff options
author | Lars Wirzenius <liw@liw.fi> | 2017-10-12 11:36:27 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2017-10-12 11:36:27 +0300 |
commit | 3bd8b255e7336fdadfd53ea94f59f10c7d621456 (patch) | |
tree | b287e48af352accacbb6529902f760cfe12c0415 | |
parent | 38cf6347845dba9eb1613d930bfd00e09da58fc6 (diff) | |
download | qvisqve-3bd8b255e7336fdadfd53ea94f59f10c7d621456.tar.gz |
Refactor: move get_current_timestamp into its own module
-rw-r--r-- | qvarn/__init__.py | 1 | ||||
-rw-r--r-- | qvarn/api.py | 10 | ||||
-rw-r--r-- | qvarn/timestamp.py | 25 | ||||
-rw-r--r-- | without-tests | 2 |
4 files changed, 29 insertions, 9 deletions
diff --git a/qvarn/__init__.py b/qvarn/__init__.py index f270cba..7e3d221 100644 --- a/qvarn/__init__.py +++ b/qvarn/__init__.py @@ -97,5 +97,6 @@ from .responses import ( from .router import Router from .version_router import VersionRouter +from .timestamp import get_current_timestamp from .api import QvarnAPI, NoSuchResourceType diff --git a/qvarn/api.py b/qvarn/api.py index 7dfd20c..9719a56 100644 --- a/qvarn/api.py +++ b/qvarn/api.py @@ -16,7 +16,6 @@ import io import os -import time import yaml @@ -504,7 +503,7 @@ class QvarnAPI: 'resource_id': rid, 'resource_revision': rrev, 'resource_change': change, - 'timestamp': self.get_current_timestamp(), + 'timestamp': qvarn.get_current_timestamp(), } for listener in self.find_listeners(rid, change): obj['listener_id'] = listener['id'] @@ -529,13 +528,6 @@ class QvarnAPI: return True return False - def get_current_timestamp(self): # pragma: no cover - t = time.time() - tm = time.gmtime(t) - ss = t - int(t) - secs = '%f' % ss - return time.strftime('%Y-%m-%dT%H:%M:%S', tm) + secs[1:] - def get_post_callback(self, coll): # pragma: no cover def wrapper(content_type, body, **kwargs): if content_type != 'application/json': diff --git a/qvarn/timestamp.py b/qvarn/timestamp.py new file mode 100644 index 0000000..355bee0 --- /dev/null +++ b/qvarn/timestamp.py @@ -0,0 +1,25 @@ +# Copyright (C) 2017 Lars Wirzenius +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + + +import time + + +def get_current_timestamp(): + t = time.time() + tm = time.gmtime(t) + ss = t - int(t) + secs = '%f' % ss + return time.strftime('%Y-%m-%dT%H:%M:%S', tm) + secs[1:] diff --git a/without-tests b/without-tests index a1ae586..636b24c 100644 --- a/without-tests +++ b/without-tests @@ -1,10 +1,12 @@ setup.py qvarn/__init__.py qvarn/backend.py +qvarn/file_router.py qvarn/logging.py qvarn/responses.py qvarn/router.py qvarn/sql.py +qvarn/timestamp.py qvarn/version.py qvarn/version_router.py yarns/lib.py |