コード例 #1
0
    def load(cls, file_name):
        """
        This method loads the code_template from XML file.

        Returns:

            * **Types** (:class:`boolean<boolean>`)
        """
        # load the code_template
        if os.path.exists(file_name) is False:
            return
        parser = XMLParser(file_name)

        if parser.getTag(tag_name) is None:
            return None

        try:
            code_template = CodeTemplate()
            code_template.name = parser.getTagAttr(tag_name, "name")
            code_template.type = parser.getTagAttr(tag_name, "type")
            code_template.description = parser.getTagAttr(
                tag_name, "description")
            code_template.language = parser.getTagAttr(tag_name, "language")
            code_template.extension = parser.getTagAttr(tag_name, "extension")
            code_template.source = parser.getTagAttr(tag_name, "source")
            code_template.command = parser.getTag(tag_name).getTag(
                "command").getText()
            code_template.code = parser.getTag(tag_name).getTag(
                "code").getText()
        except:
            return None

        if code_template.name == "":
            return None
        return code_template
コード例 #2
0
 def __save(self):
     code_template = CodeTemplate()
     code_template.name = self.name.get_value()
     code_template.type = self.type.get_value()
     code_template.description = self.description.get_value()
     code_template.language = self.language.get_value()
     code_template.command = self.command.get_value()
     code_template.extension = self.extension.get_value()
     code_template.code = self.code.get_value()
     self.code_template_manager.add_code_template(code_template)
コード例 #3
0
    def test_add_code_template(self):
        code_template = CodeTemplate()
        self.assertIsNone(
            self.codetemplatemanager.add_code_template(code_template))

        code_template.type = "Language Test"
        code_template.name = "Testando Code Template"
        code_template.description = "Um teste para code template em Add Code Template"
        code_template.language = ""
        code_template.command = ""
        code_template.extension = "teste"
        code_template.code = "Testando 1 2 3"
        code_template.source = "python"
        self.assertIsNone(
            self.codetemplatemanager.add_code_template(code_template))
コード例 #4
0
    def load(cls, file_name):
        """
        This method loads the code_template from XML file.

        Returns:

            * **Types** (:class:`boolean<boolean>`)
        """
        # load the code_template
        if os.path.exists(file_name) is False:
            return None
        parser = XMLParser(file_name)

        if parser.getTag(tag_name) is None:
            return None

        try:
            code_template = CodeTemplate()
            code_template.name = parser.getTagAttr(tag_name, "name")
            code_template.type = parser.getTagAttr(tag_name, "type")
            code_template.description = parser.getTagAttr(
                tag_name, "description")
            code_template.language = parser.getTagAttr(tag_name, "language")
            code_template.command = parser.getTag(tag_name).getTag(
                "command").getText()
            code_template.extension = parser.getTagAttr(tag_name, "extension")
            code_template.code = parser.getTag(tag_name).getTag(
                "code").getText()

            code_parts = parser.getTag(tag_name).getTag(
                "code_parts").getChildTags("code_part")
            for code_part in code_parts:
                code_template.code_parts.append(code_part.getAttr("value"))

        except Exception as e:
            print e
            return None

        if code_template.name == "":
            return None
        return code_template