dictation-toolbox / dragonfly

Speech recognition framework allowing powerful Python-based scripting and extension of Dragon NaturallySpeaking (DNS), Windows Speech Recognition (WSR), Kaldi and CMU Pocket Sphinx
GNU Lesser General Public License v3.0
388 stars 75 forks source link

Fix clipboard incorrect handling of None type #319

Closed MarkRx closed 3 years ago

MarkRx commented 3 years ago

Fixes a bug where the clipboard does not properly handle 'None'

>>> import dragonfly.util.clipboard
>>> clip = dragonfly.util.clipboard.Clipboard()
>>> clip.has_text()
False
>>> clip.set_text('None')
>>> clip.has_text()
True
>>> clip.get_text()
'None'
>>> clip.set_text(None)
>>> clip.has_text()
False
>>> clip.get_text()
>>> clip.set_text(False)
>>> clip.has_text()
True
>>> clip.get_text()
'False'
>>> import dragonfly.windows.clipboard
>>> clip2 = dragonfly.windows.clipboard.Clipboard()
>>> clip2.has_text()
False
>>> clip2.set_text('None')
>>> clip2.has_text()
True
>>> clip2.get_text()
'None'
>>> clip2.set_text(None)
>>> clip2.has_text()
False
>>> clip2.get_text()
>>> clip2.set_text(False)
>>> clip2.has_text()
True
>>> clip2.get_text()
'False'
drmfinlay commented 3 years ago

Thanks! This looks good to me. Sorry I took a while to respond. I will add relevant test cases to test_clipboard.py and merge soon.