[vlille] improve method _get_sensor_by_id (suggested by
Herve Werner)
This commit is contained in:
parent
fa02fc4aa4
commit
3c66071e05
1 changed files with 10 additions and 5 deletions
|
|
@ -16,7 +16,7 @@
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
import re
|
||||||
|
|
||||||
from weboob.tools.backend import BaseBackend
|
from weboob.tools.backend import BaseBackend
|
||||||
from weboob.capabilities.gauge import ICapGauge, GaugeSensor, Gauge, SensorNotFound
|
from weboob.capabilities.gauge import ICapGauge, GaugeSensor, Gauge, SensorNotFound
|
||||||
|
|
@ -75,8 +75,13 @@ class VlilleBackend(BaseBackend, ICapGauge):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _get_sensor_by_id(self, id):
|
def _get_sensor_by_id(self, id):
|
||||||
for gauge in self.browser.get_station_list():
|
reSensorId = re.search('(\d+)-((bikes|attach|status))', id, re.IGNORECASE)
|
||||||
for sensor in self.browser.get_station_infos(gauge):
|
if reSensorId:
|
||||||
if id == sensor.id:
|
gauge = reSensorId.group(1)
|
||||||
return sensor
|
pattern = reSensorId.group(2)
|
||||||
|
sensor_generator = self.iter_sensors(gauge, pattern)
|
||||||
|
if sensor_generator:
|
||||||
|
return next(sensor_generator)
|
||||||
|
else:
|
||||||
|
return None
|
||||||
return None
|
return None
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue