parent
ba2618d035
commit
8487bdb83e
|
@ -166,6 +166,7 @@ class Bookmarks:
|
||||||
autojoin_val = conf.getAttr('autojoin')
|
autojoin_val = conf.getAttr('autojoin')
|
||||||
if not autojoin_val: # not there (it's optional)
|
if not autojoin_val: # not there (it's optional)
|
||||||
autojoin_val = False
|
autojoin_val = False
|
||||||
|
|
||||||
minimize_val = conf.getTag('minimize', namespace=NS_GAJIM_BM)
|
minimize_val = conf.getTag('minimize', namespace=NS_GAJIM_BM)
|
||||||
if not minimize_val: # not there, try old Gajim behaviour
|
if not minimize_val: # not there, try old Gajim behaviour
|
||||||
minimize_val = conf.getAttr('minimize')
|
minimize_val = conf.getAttr('minimize')
|
||||||
|
@ -189,19 +190,27 @@ class Bookmarks:
|
||||||
conf.getAttr('jid'))
|
conf.getAttr('jid'))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
bookmark = {
|
||||||
|
'name': conf.getAttr('name'),
|
||||||
|
'password': conf.getTagData('password'),
|
||||||
|
'nick': conf.getTagData('nick'),
|
||||||
|
'print_status': print_status
|
||||||
|
}
|
||||||
|
|
||||||
|
try:
|
||||||
|
bookmark['autojoin'] = from_xs_boolean(autojoin_val)
|
||||||
|
bookmark['minimize'] = from_xs_boolean(minimize_val)
|
||||||
|
except ValueError as error:
|
||||||
|
log.warning(error)
|
||||||
|
continue
|
||||||
|
|
||||||
if check_merge:
|
if check_merge:
|
||||||
if jid in self.bookmarks:
|
if jid in self.bookmarks:
|
||||||
continue
|
continue
|
||||||
merged = True
|
merged = True
|
||||||
|
|
||||||
log.debug('Found Bookmark: %s', jid)
|
log.debug('Found Bookmark: %s', jid)
|
||||||
self.bookmarks[jid] = {
|
self.bookmarks[jid] = bookmark
|
||||||
'name': conf.getAttr('name'),
|
|
||||||
'autojoin': from_xs_boolean(autojoin_val),
|
|
||||||
'minimize': from_xs_boolean(minimize_val),
|
|
||||||
'password': conf.getTagData('password'),
|
|
||||||
'nick': conf.getTagData('nick'),
|
|
||||||
'print_status': print_status}
|
|
||||||
|
|
||||||
return merged
|
return merged
|
||||||
|
|
||||||
|
|
|
@ -47,20 +47,16 @@ def is_muc_pm(message: nbxmpp.Node,
|
||||||
|
|
||||||
|
|
||||||
def from_xs_boolean(value: Union[str, bool]) -> bool:
|
def from_xs_boolean(value: Union[str, bool]) -> bool:
|
||||||
# Convert a xs:boolean ('true', 'false', '1', '0', '')
|
|
||||||
# to a python boolean (True, False)
|
|
||||||
if isinstance(value, bool):
|
if isinstance(value, bool):
|
||||||
return value
|
return value
|
||||||
|
|
||||||
if value in ('1', 'true'):
|
if value in ('1', 'true', 'True'):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# '0', 'false' or empty
|
if value in ('0', 'false', 'False', ''):
|
||||||
if value in ('0', 'false', ''):
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
raise ValueError(
|
raise ValueError('Cant convert %s to python boolean' % value)
|
||||||
'Cant convert %s to python boolean' % value)
|
|
||||||
|
|
||||||
|
|
||||||
def to_xs_boolean(value: Union[bool, None]) -> str:
|
def to_xs_boolean(value: Union[bool, None]) -> str:
|
||||||
|
|
Loading…
Reference in New Issue