def generate_license(self):
        """ Generate LICENSE by using Packager.license.

            :param generalpackager.Packager self: """
        text = Path(self.localrepo.get_repos_path() /
                    f"generalpackager/generalpackager/licenses/{self.license}"
                    ).text.read()
        assert "$" in text
        text = text.replace("$year", str(Date.now().datetime.year))
        text = text.replace("$author", self.author)
        assert "$" not in text

        return text
Example #2
0
    def test_text_replace_regex(self):
        for path in self.paths:
            text = Path(path).text

            text.write("hello this is a test")

            text.replace({".+": "foo52bar"}, regex=True)
            self.assertEqual("foo52bar", text.read())

            text.replace({".+": "foo52bar"}, regex=True)
            self.assertEqual("foo52bar", text.read())

            text.replace({"\d+": ""}, regex=True)
            self.assertEqual("foobar", text.read())
Example #3
0
    def test_text_replace(self):
        for path in self.paths:
            text = Path(path).text

            text.write("hello this is a test")

            text.replace({"this": "that"})
            self.assertEqual("hello that is a test", text.read())

            text.replace({"that is": "what"})
            self.assertEqual("hello what a test", text.read())

            text.replace({"hello": "hi", "a test": "are tests"})
            self.assertEqual("hi what are tests", text.read())