Make in-class decorator autonomous function

This commit is contained in:
Alexey Zakharenkov 2019-03-22 13:28:27 +03:00
parent 02fe92a764
commit fc1ed869a9

View file

@ -40,6 +40,16 @@ class DummyCache:
return method
def _skip_if_not_used(func):
"""Decorator to skip method execution under certain condition.
Relies on "is_used" object property."""
def inner(self, *args, **kwargs):
if not self.is_used:
return
return func(self, *args, **kwargs)
return inner
class MapsmeCache:
def __init__(self, cache_path, cities):
if not cache_path:
@ -81,14 +91,6 @@ class MapsmeCache:
return True
def _skip_if_not_used(func):
"""Decorator to skip method execution under certain condition."""
def inner(self, *args, **kwargs):
if not self.is_used:
return
return func(self, *args, **kwargs)
return inner
@_skip_if_not_used
def provide_stops_and_networks(self, stops, networks):
"""Put stops and networks for bad cities into containers