Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def to_string(something):
if isinstance(something, ut.basestring):
return something
try:
text = "".join(something) # convert a list or a tuple to a string
except:
db.msgbox(
"Exception when trying to convert {} to text in self.textArea"
.format(type(something)))
sys.exit(16)
return text
title = "Demo of textbox: Classic box"
gnexp = "This is a demo of the classic textbox call, \
you can see it closes when ok is pressed.\n\n"
msg = "INSERT A TEXT WITH MORE THAN TWO PARAGRAPHS"
text_snippet = "Insert your text here\n"
reply = textbox(gnexp + msg, title, text_snippet, None)
if reply.count("\n") >= 2:
db.msgbox(u"You did it right!")
else:
db.msgbox(u"You did it wrong!")
def demo_1():
title = "Demo of textbox: Classic box"
gnexp = "This is a demo of the classic textbox call, \
you can see it closes when ok is pressed.\n\n"
msg = "INSERT A TEXT WITH MORE THAN TWO PARAGRAPHS"
text_snippet = "Insert your text here\n"
reply = textbox(gnexp + msg, title, text_snippet, None)
if reply.count("\n") >= 2:
db.msgbox(u"You did it right!")
else:
db.msgbox(u"You did it wrong!")
sections = ['\n', separator, timeString, separator,
errmsg, separator, tbinfo]
try:
msg = '\n'.join(sections)
except TypeError as e:
# Remove all things not string.
sections = [item for item in sections if type(item) == str]
msg = '\n'.join(sections)
try:
f = codecs.open(logFile, "a+", encoding='utf-8')
f.write(msg)
f.close()
except IOError as e:
msgbox("unable to write to {0}".format(logFile), "Writing error")
# always show an error message
try:
if not _isQAppRunning():
app = QtGui.QApplication([])
_showMessageBox(str(notice) + str(msg))
except:
msgbox(str(notice) + str(msg), "Error")
def demo_ynbox():
title = "Demo of ynbox"
msg = "Were you expecting the Spanish Inquisition?"
reply = ynbox(msg, title)
print("Reply was: {!r}".format(reply))
if reply:
msgbox("NOBODY expects the Spanish Inquisition!", "Wrong!")
return reply
def demo_msgbox():
reply = msgbox("short msg", "This is a long title")
print("Reply was: {!r}".format(reply))
return reply
msg = '\n'.join(sections)
try:
f = codecs.open(logFile, "a+", encoding='utf-8')
f.write(msg)
f.close()
except IOError as e:
msgbox("unable to write to {0}".format(logFile), "Writing error")
# always show an error message
try:
if not _isQAppRunning():
app = QtGui.QApplication([])
_showMessageBox(str(notice) + str(msg))
except:
msgbox(str(notice) + str(msg), "Error")