X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;f=sima%2Futils%2Futils.py;fp=sima%2Futils%2Futils.py;h=475a54859305d2dbbff604546a6333b05c97eac6;hb=78a694ddcd2a6ecc8b2b1fd3c74ee2d938707305;hp=d0edcd4ab6f8ca671143df6fbfe8e0e97ac44cc0;hpb=300d9624d0c3bf2218a8df59eff689f5b78a2025;p=mpd-sima.git diff --git a/sima/utils/utils.py b/sima/utils/utils.py index d0edcd4..475a548 100644 --- a/sima/utils/utils.py +++ b/sima/utils/utils.py @@ -20,6 +20,7 @@ # """generic tools and utilities for sima """ +# pylint: disable=C0111 import traceback import sys @@ -79,6 +80,8 @@ def exception_log(): sys.exit(1) def purge_cache(obj, age=4): + """purge old entries in http client cache + """ now = datetime.utcnow() if now.hour == obj.timestamp.hour: return @@ -92,6 +95,7 @@ def purge_cache(obj, age=4): class SigHup(Exception): + """SIGHUP raises this Exception""" pass # ArgParse Callbacks @@ -158,7 +162,8 @@ class Wdir(FileAction): if not access(self._file, W_OK): self.parser.error('no write access to "{0}"'.format(self._file)) -class Throttle(): +class Throttle: + """throttle decorator""" def __init__(self, wait): self.wait = wait self.last_called = datetime.now() @@ -172,7 +177,8 @@ class Throttle(): return result return wrapper -class Cache(): +class Cache: + """Plain cache object""" def __init__(self, elem, last=None): self.elem = elem self.requestdate = last