Add search address method. enable/disable in mpybit
This commit is contained in:
parent
d51faba252
commit
1b48f96340
|
@ -4,6 +4,7 @@ BMConfigParser class definition and default configuration settings
|
||||||
# pylint: disable=no-self-use, arguments-differ
|
# pylint: disable=no-self-use, arguments-differ
|
||||||
import configparser
|
import configparser
|
||||||
import os
|
import os
|
||||||
|
import shared
|
||||||
import shutil
|
import shutil
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
@ -194,18 +195,27 @@ class BMConfigParser(configparser.ConfigParser):
|
||||||
if value < 0 or value > 8:
|
if value < 0 or value > 8:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def search_addresses(address, searched_text):
|
def search_addresses(address, searched_text):
|
||||||
return [x for x in [BMConfigParser().get(address, 'label').lower(), address.lower()]
|
"""Return the searched label of MyAddress"""
|
||||||
if searched_text in x]
|
return [x for x in [BMConfigParser().get(address, 'label').lower(),
|
||||||
|
address.lower()] if searched_text in x]
|
||||||
|
|
||||||
def disable_address(self, address):
|
def disable_address(self, address):
|
||||||
""""To disable the Address"""
|
""""To disable the Address"""
|
||||||
self.set(str(address), 'enabled', 'false')
|
try:
|
||||||
self.save()
|
self.set(str(address), 'enabled', 'false')
|
||||||
|
self.save()
|
||||||
|
shared.reloadMyAddressHashes()
|
||||||
|
except (KeyError, TypeError) as e:
|
||||||
|
raise configparser.NoSectionError(e)
|
||||||
|
|
||||||
def enable_address(self, address):
|
def enable_address(self, address):
|
||||||
""""To enable the Address"""
|
""""To enable the Address"""
|
||||||
self.set(address, 'enabled', 'true')
|
try:
|
||||||
self.save()
|
self.set(address, 'enabled', 'true')
|
||||||
|
self.save()
|
||||||
|
shared.reloadMyAddressHashes()
|
||||||
|
except (KeyError, TypeError) as e:
|
||||||
|
raise configparser.NoSectionError(e)
|
||||||
|
|
Reference in New Issue
Block a user