Beispiel #1
0
 def _cut_off(self, text):
     cut_text = ""
     for char in text:
         if tweetLength(cut_text) >= 140:
             break
         else:
             cut_text += char
     return cut_text
Beispiel #2
0
 def test_tweetLength(self):
     self.assertEqual(tweetLength("【转基因"), 4)
     self.assertEqual(tweetLength("我司CEO!"), 5)
     self.assertEqual(tweetLength("8@&*%&b"), 4)
     self.assertEqual(tweetLength(" Test"), 3)
     self.assertEqual(tweetLength("   Test   "), 5)
     self.assertEqual(tweetLength("   Testing    "), 14)
Beispiel #3
0
 def test_tweetLength(self):
     self.assertEqual(tweetLength("【转基因"), 4)
     self.assertEqual(tweetLength("我司CEO!"), 5)
     self.assertEqual(tweetLength("8@&*%&b"), 4)
     self.assertEqual(tweetLength(" Test"), 3)
     self.assertEqual(tweetLength("   Test   "), 5)
     self.assertEqual(tweetLength("   Testing    "), 14)
Beispiel #4
0
    def checkChars(self):
        """Check textEdit's characters.
        If it larger than 140, Send Button will be disabled
        and label will show red chars."""

        text = self.textEdit.toPlainText()
        numLens = 140 - tweetLength(text)
        if numLens == 140 and (not self.action == "retweet"):
            # you can not send empty tweet, except retweet
            self.pushButton_send.setEnabled(False)
        elif numLens >= 0:
            # length is okay
            self.label.setStyleSheet("color:black;")
            self.pushButton_send.setEnabled(True)
        else:
            # text is too long
            self.label.setStyleSheet("color:red;")
            self.pushButton_send.setEnabled(False)
        self.label.setText(str(numLens))
Beispiel #5
0
    def checkChars(self):
        """Check textEdit's characters.
        If it larger than 140, Send Button will be disabled
        and label will show red chars."""

        text = self.textEdit.toPlainText()
        numLens = 140 - tweetLength(text)
        if numLens == 140 and (not self.action == "retweet"):
            # you can not send empty tweet, except retweet
            self.pushButton_send.setEnabled(False)
        elif numLens >= 0:
            # length is okay
            self.label.setStyleSheet("color:black;")
            self.pushButton_send.setEnabled(True)
        else:
            # text is too long
            self.label.setStyleSheet("color:red;")
            self.pushButton_send.setEnabled(False)
        self.label.setText(str(numLens))