Untitled

From lovetox, 2 Years ago, written in Plain Text, viewed 173 times. This paste will join the choir invisible in 1 Second.
URL https://paste.gajim.org/view/6067d32a Embed
Download Paste or View Raw
  1. def from_xs_boolean(value):
  2.     # Convert a xs:boolean ('true', 'false', '1', '0', '')
  3.     # to a python boolean (True, False)
  4.     if value in (True, False):
  5.         return value
  6.  
  7.     if value in ('1', 'true'):
  8.         return True
  9.  
  10.     # '0', 'false' or empty
  11.     if value in ('0', 'false', ''):
  12.         return False
  13.  
  14.     raise ValueError(
  15.         'Cant convert %s to python boolean' % value)
  16.  

Reply to "Untitled"

Here you can reply to the paste above