Make in-class decorator autonomous function
This commit is contained in:
parent
02fe92a764
commit
fc1ed869a9
1 changed files with 10 additions and 8 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue