Ejemplo n.º 1
0
 def test_derivePermlink(self):
     self.assertEqual(derive_permlink("Hello World"), "hello-world")
     self.assertEqual(derive_permlink("aAf_0.12"), "aaf-0-12")
     self.assertEqual(derive_permlink("[](){}"), "")
     self.assertEqual(len(derive_permlink("", parent_permlink=256 * "a")),
                      256)
     self.assertEqual(
         len(
             derive_permlink("",
                             parent_permlink=256 * "a",
                             parent_author="test")), 256)
Ejemplo n.º 2
0
 def test_derivePermlink(self):
     self.assertTrue(derive_permlink("Hello World").startswith("hello-world"))
     self.assertTrue(derive_permlink("aAf_0.12").startswith("aaf-0-12"))
     title = "[](){}"
     permlink = derive_permlink(title)
     self.assertFalse(permlink.startswith("-"))
     for char in title:
         self.assertFalse(char in permlink)
     self.assertEqual(len(derive_permlink("", parent_permlink=256 * "a")), 256)
     self.assertEqual(len(derive_permlink("", parent_permlink=256 * "a", parent_author="test")), 256)
     self.assertEqual(len(derive_permlink("a" * 1024)), 256)
Ejemplo n.º 3
0
    def diff_files_into_text_areas(self):
        try:
            content = open(self.rightFile, "r", encoding="utf8").read()
        except Exception as e:
            showerror("Unable to read " + self.rightFile, str(e))
            content = ''

        rightFileContents, parameter = seperate_yaml_dict_from_body(content)        
        
        if "permlink" in parameter:
            authorperm = construct_authorperm(parameter["author"], parameter["permlink"])
        else:
            authorperm = construct_authorperm(parameter["author"], derive_permlink(parameter["title"], with_suffix=False))
        self.__main_window_ui.leftFileLabel.config(text=authorperm)        
        try:
            comment = Comment(authorperm)
            leftFileContents = comment.body
        except:
            leftFileContents = ''
        self.show_content(leftFileContents, rightFileContents)
Ejemplo n.º 4
0
 def test_derivePermlink(self):
     self.assertEqual(derive_permlink("Hello World"), "hello-world")
     self.assertEqual(derive_permlink("aAf_0.12"), "aaf-0-12")
     self.assertEqual(derive_permlink("[](){}"), "")
            if v["voter"] == rewarding_account:
                already_voted = True
        if already_voted:
            continue

        if c_comment.is_main_post():
            c = c_comment
        else:
            c = Comment(construct_authorperm(c_comment["parent_author"],
                                             c_comment["parent_permlink"]),
                        steem_instance=stm)
        if not (c.is_pending() and valid_age(c)):
            body = "The reward of this comment goes 100 %% to the author %s. This is done by setting the beneficiaries of this comment to 100 %%.\n\n" % (
                c["author"])
            comment_beneficiaries = [{"account": c["author"], "weight": 10000}]
            permlink = derive_permlink("rewarding %s" % c["author"],
                                       c_comment["permlink"])
            stm.post("rewarding %s" % c["author"],
                     body,
                     author=rewarding_account,
                     permlink=permlink,
                     reply_identifier=c_comment["authorperm"],
                     beneficiaries=comment_beneficiaries)
            time.sleep(3)

            authorperm = construct_authorperm(rewarding_account, permlink)
            comment_timestamp = datetime.utcnow()
            main_post = False
        else:
            authorperm = c["authorperm"]
            main_post = c.is_main_post()
            comment_timestamp = c["created"].replace(tzinfo=None)