def _build_application_directory(context, components_dict):
        """
        Builds the application directory components of the output

        :param context: The template context
        :param components_dict: Dictionary containing components by name (and other info)
        :return: The application directory components of the output
        """
        def _get_additional_imports():
            """
            Outputs the imports for the "app.py" file (based on whether event and/or request callbacks
            have been defined in the configuration)
            :return: The imports for the "app.py" file (based on whether event and/or request callbacks
                have been defined in the configuration)
            """
            ret = ""
            if components_dict["has_events"] or components_dict["has_services"]:
                ret += "\n"
                if components_dict["has_services"]:
                    ret += "from dxlclient.service import ServiceRegistrationInfo\n"
                    ret += "from requesthandlers import *\n"
                if components_dict["has_events"]:
                    ret += "from eventhandlers import *\n"
            return ret

        config = context.template.template_config
        app_section = config.application_section
        root = components_dict["root"]

        app_dir = DirTemplateComponent(app_section.name)
        root.add_child(app_dir)
        components_dict["app_dir"] = app_dir

        file_comp = FileTemplateComponent(
            "__init__.py", "app/__init__.py.tmpl", {
                "appClassName": app_section.app_class_name,
                "relPackage": ".app"
            })
        app_dir.add_child(file_comp)

        app_file_comp = FileTemplateComponent(
            "app.py", "app/app.py.tmpl", {
                "appClassName": app_section.app_class_name,
                "name": app_section.name,
                "fullName": app_section.full_name,
                "additionalImports": _get_additional_imports
            })
        components_dict["app_file_comp"] = app_file_comp

        app_dir.add_child(app_file_comp)

        file_comp = FileTemplateComponent(
            "__main__.py", "app/__main__.py.tmpl", {
                "appClassName": app_section.app_class_name,
                "name": app_section.name
            })
        app_dir.add_child(file_comp)
    def _build_sample_directory(context, components_dict):
        """
        Builds the "sample" directory components of the output

        :param context: The template context
        :param components_dict: Dictionary containing components by name (and other info)
        :return: The "sample" directory components of the output
        """
        config = context.template.template_config
        client_section = config.client_section
        root = components_dict["root"]

        sample_dir = DirTemplateComponent("sample")
        root.add_child(sample_dir)

        ClientTemplate._copy_sample_files(context, components_dict, sample_dir)

        file_comp = FileTemplateComponent(
            "common.py", "../../app/static/sample/common.py.tmpl")
        sample_dir.add_child(file_comp)

        sample_basic_dir = DirTemplateComponent("basic")
        sample_dir.add_child(sample_basic_dir)

        include_example = client_section.include_example_method
        basic_sample_comp = FileTemplateComponent(
            "basic_sample.py", "sample/basic/basic_sample.py.tmpl", {
                "clientClassName":
                client_section.client_class_name,
                "name":
                client_section.name,
                "additionalImports":
                ("from dxlbootstrap.util import MessageUtils\n"
                 if include_example else "")
            })
        if include_example:
            comp = CodeTemplateComponent(
                "sample/basic/code/invoke_example_method.code.tmpl")
            comp.indent_level = 1
            basic_sample_comp.add_child(comp)

        sample_basic_dir.add_child(basic_sample_comp)
    def _build_schema_directory(context, components_dict):
        """
        Builds the "schema" directory components of the output

        :param context: The template context
        :param components_dict: Dictionary containing components by name (and other info)
        :return: The "schema" directory components of the output
        """

        root = components_dict["root"]

        schema_dir = DirTemplateComponent("schema")
        root.add_child(schema_dir)

        schema_version_dir = DirTemplateComponent("v0.1")
        schema_dir.add_child(schema_version_dir)

        components_dict["schema_comp"] = schema_dir

        AppTemplate._copy_schema_files(context, components_dict,
                                       schema_version_dir)
示例#4
0
    def _build_config_directory(context, components_dict):
        """
        Builds the "config" directory components of the output

        :param context: The template context
        :param components_dict: Dictionary containing components by name (and other info)
        :return: The "config" directory components of the output
        """
        root = components_dict["root"]

        config_dir = DirTemplateComponent("config")
        root.add_child(config_dir)

        AppTemplate._copy_config_files(context, components_dict, config_dir)
示例#5
0
    def _build_sample_directory(context, components_dict):
        """
        Builds the "sample" directory components of the output

        :param context: The template context
        :param components_dict: Dictionary containing components by name (and other info)
        :return: The "sample" directory components of the output
        """
        root = components_dict["root"]

        sample_dir = DirTemplateComponent("sample")
        root.add_child(sample_dir)
        AppTemplate._copy_sample_files(context, components_dict, sample_dir)

        file_comp = FileTemplateComponent("common.py", "sample/common.py.tmpl")
        sample_dir.add_child(file_comp)

        sample_basic_dir = DirTemplateComponent("basic")
        sample_dir.add_child(sample_basic_dir)

        basic_sample_comp = FileTemplateComponent(
            "basic_sample.py", "sample/basic/basic_sample.py.tmpl")
        sample_basic_dir.add_child(basic_sample_comp)
        components_dict["basic_sample_comp"] = basic_sample_comp
    def _build_docs_directory(self, context, components_dict):
        """
        Builds the "docs" directory components of the output

        :param context: The template context
        :param components_dict: Dictionary containing components by name (and other info)
        :return: The "docs" directory components of the output
        """
        config = context.template.template_config
        app_section = config.application_section
        root = components_dict["root"]

        doc_dir = DirTemplateComponent("doc")
        root.add_child(doc_dir)

        file_comp = FileTemplateComponent(
            "conf.py", "doc/conf.py.tmpl", {
                "copyright": app_section.copyright,
                "fullName": app_section.full_name,
                "name": app_section.name
            })
        doc_dir.add_child(file_comp)

        sdk_dir = DirTemplateComponent("sdk")
        doc_dir.add_child(sdk_dir)

        file_comp = FileTemplateComponent(
            "index.rst", "doc/sdk/index.rst.tmpl", {
                "fullName":
                app_section.full_name,
                "fullNameSep":
                self.create_underline(len(app_section.full_name), "="),
                "name":
                app_section.name
            })
        sdk_dir.add_child(file_comp)

        file_comp = FileTemplateComponent(
            "README.html", "doc/sdk/README.html.tmpl", {
                "copyright": app_section.copyright,
                "fullName": app_section.full_name
            })
        sdk_dir.add_child(file_comp)

        file_comp = FileTemplateComponent("overview.rst",
                                          "doc/sdk/overview.rst.tmpl")
        sdk_dir.add_child(file_comp)

        file_comp = FileTemplateComponent("installation.rst",
                                          "doc/sdk/installation.rst.tmpl",
                                          {"name": app_section.name})
        sdk_dir.add_child(file_comp)
        file_comp = FileTemplateComponent("running.rst",
                                          "doc/sdk/running.rst.tmpl",
                                          {"name": app_section.name})
        sdk_dir.add_child(file_comp)

        config_title = "{0} ({1}.config)".format(app_section.full_name,
                                                 app_section.name)
        file_comp = FileTemplateComponent(
            "configuration.rst", "doc/sdk/configuration.rst.tmpl", {
                "fullName": app_section.full_name,
                "name": app_section.name,
                "configTitle": config_title,
                "configTitleSep": self.create_underline(
                    len(config_title), "-")
            })
        sdk_dir.add_child(file_comp)

        file_comp = FileTemplateComponent("sampleconfig.rst",
                                          "doc/sdk/sampleconfig.rst.tmpl",
                                          {"fullName": app_section.full_name})
        sdk_dir.add_child(file_comp)
    def _build_config_directory(context, components_dict):
        """
        Builds the "config" directory components of the output

        :param context: The template context
        :param components_dict: Dictionary containing components by name (and other info)
        :return: The "config" directory components of the output
        """
        config = context.template.template_config
        app_section = config.application_section
        root = components_dict["root"]

        config_dir = DirTemplateComponent("config")
        root.add_child(config_dir)

        file_comp = FileTemplateComponent("logging.config",
                                          "config/logging.config.tmpl")
        config_dir.add_child(file_comp)
        file_comp = FileTemplateComponent("logging.config.dist",
                                          "config/logging.config.tmpl")
        config_dir.add_child(file_comp)
        file_comp = FileTemplateComponent("dxlclient.config",
                                          "config/dxlclient.config.tmpl")
        config_dir.add_child(file_comp)
        file_comp = FileTemplateComponent("dxlclient.config.dist",
                                          "config/dxlclient.config.tmpl")
        config_dir.add_child(file_comp)
        file_comp = FileTemplateComponent(app_section.name + ".config",
                                          "config/app.config.tmpl",
                                          {"fullName": app_section.full_name})
        config_dir.add_child(file_comp)
        file_comp = FileTemplateComponent(app_section.name + ".config.dist",
                                          "config/app.config.tmpl",
                                          {"fullName": app_section.full_name})
        config_dir.add_child(file_comp)
    def _build_root_directory(self, context, components_dict):
        """
        Builds the "root" directory components of the output

        :param context: The template context
        :param components_dict: Dictionary containing components by name (and other info)
        :return: The "root" directory components of the output
        """
        config = context.template.template_config
        app_section = config.application_section

        root = DirTemplateComponent("")
        components_dict["root"] = root

        file_comp = FileTemplateComponent(
            "README", "README.tmpl", {
                "fullName":
                app_section.full_name,
                "fullNameSep":
                self.create_underline(len(app_section.full_name), "="),
                "copyright":
                app_section.copyright
            })
        root.add_child(file_comp)

        file_comp = FileTemplateComponent("README.md", "README.md.tmpl", {
            "fullName": app_section.full_name,
            "copyright": app_section.copyright
        })
        root.add_child(file_comp)

        file_comp = FileTemplateComponent(
            "setup.py", "setup.py.tmpl", {
                "name":
                app_section.name,
                "installRequires":
                self.create_install_requires(app_section.install_requires)
            })
        root.add_child(file_comp)

        file_comp = FileTemplateComponent("LICENSE", "LICENSE.tmpl")
        root.add_child(file_comp)

        file_comp = FileTemplateComponent("MANIFEST.in", "MANIFEST.in.tmpl")
        root.add_child(file_comp)

        file_comp = FileTemplateComponent("dist.py", "dist.py.tmpl",
                                          {"name": app_section.name})
        root.add_child(file_comp)

        file_comp = FileTemplateComponent("clean.py", "clean.py.tmpl",
                                          {"name": app_section.name})
        root.add_child(file_comp)

        file_comp = FileTemplateComponent(
            "Dockerfile", "Dockerfile.tmpl", {
                "name": app_section.name,
                "pipInstall": self.create_pip_install(config)
            })
        root.add_child(file_comp)
示例#9
0
    def _build_docs_directory(self, context, components_dict):
        """
        Builds the "docs" directory components of the output

        :param context: The template context
        :param components_dict: Dictionary containing components by name (and other info)
        :return: The "docs" directory components of the output
        """
        config = context.template.template_config
        client_section = config.client_section
        root = components_dict["root"]

        doc_dir = DirTemplateComponent("doc")
        root.add_child(doc_dir)

        file_comp = FileTemplateComponent("conf.py", "../../app/static/doc/conf.py.tmpl",
                                          {"copyright": client_section.copyright,
                                           "fullName": client_section.full_name,
                                           "name": client_section.name})
        doc_dir.add_child(file_comp)

        sdk_dir = DirTemplateComponent("sdk")
        doc_dir.add_child(sdk_dir)

        file_comp = FileTemplateComponent("index.rst", "doc/sdk/index.rst.tmpl",
                                          {"fullName": client_section.full_name,
                                           "fullNameSep":
                                               self.create_underline(len(client_section.full_name), "="),
                                           "name": client_section.name})
        sdk_dir.add_child(file_comp)

        file_comp = FileTemplateComponent("README.html", "../../app/static/doc/sdk/README.html.tmpl",
                                          {"copyright": client_section.copyright,
                                           "fullName": client_section.full_name})
        sdk_dir.add_child(file_comp)

        file_comp = FileTemplateComponent("overview.rst", "../../app/static/doc/sdk/overview.rst.tmpl")
        sdk_dir.add_child(file_comp)

        file_comp = FileTemplateComponent("installation.rst", "doc/sdk/installation.rst.tmpl",
                                          {"name": client_section.name})
        sdk_dir.add_child(file_comp)

        file_comp = FileTemplateComponent("sampleconfig.rst", "../../app/static/doc/sdk/sampleconfig.rst.tmpl",
                                          {"fullName": client_section.full_name})
        sdk_dir.add_child(file_comp)
示例#10
0
    def _build_client_directory(context, components_dict):
        """
        Builds the client directory components of the output

        :param context: The template context
        :param components_dict: Dictionary containing components by name (and other info)
        :return: The client directory components of the output
        """

        config = context.template.template_config
        client_section = config.client_section
        root = components_dict["root"]

        client_dir = DirTemplateComponent(client_section.name)
        root.add_child(client_dir)
        components_dict["client_dir"] = client_dir

        file_comp = FileTemplateComponent("__init__.py", "../../app/static/app/__init__.py.tmpl",
                                          {"appClassName": client_section.client_class_name,
                                           "relPackage": ".client"})
        client_dir.add_child(file_comp)

        file_comp = FileTemplateComponent("_version.py", "../../app/static/app/_version.py.tmpl",
                                          {"appClassName": client_section.client_class_name,
                                           "relPackage": ".client"})
        client_dir.add_child(file_comp)

        include_example = client_section.include_example_method
        file_comp = FileTemplateComponent("client.py", "client/client.py.tmpl",
                                          {"clientClassName": client_section.client_class_name,
                                           "fullName": client_section.full_name,
                                           "additionalImports":
                                               ("from dxlclient.message import Request\n"
                                                "from dxlbootstrap.util import MessageUtils\n"
                                                if include_example else "")})

        if include_example:
            comp = CodeTemplateComponent("client/code/example_method.code.tmpl")
            comp.indent_level = 1
            file_comp.add_child(comp)

        client_dir.add_child(file_comp)

        config_dir = DirTemplateComponent("_config")
        client_dir.add_child(config_dir)
        blank_init_file_comp = FileTemplateComponent("__init__.py", "../../app/static/app/__init__.py.blank.tmpl")

        config_dir.add_child(blank_init_file_comp)

        config_sample_dir = DirTemplateComponent("sample")
        config_dir.add_child(config_sample_dir)
        config_sample_dir.add_child(blank_init_file_comp)
        ClientTemplate._copy_sample_files(context, components_dict, config_sample_dir)
示例#11
0
    def _build_root_directory(self, context, components_dict):
        """
        Builds the "root" directory components of the output

        :param context: The template context
        :param components_dict: Dictionary containing components by name (and other info)
        :return: The "root" directory components of the output
        """
        config = context.template.template_config
        client_section = config.client_section

        root = DirTemplateComponent("")
        components_dict["root"] = root

        file_comp = FileTemplateComponent("README", "../../app/static/README.tmpl",
                                          {"fullName": client_section.full_name,
                                           "fullNameSep":
                                               self.create_underline(len(client_section.full_name), "="),
                                           "copyright": client_section.copyright})
        root.add_child(file_comp)

        file_comp = FileTemplateComponent("README.md", "../../app/static/README.md.tmpl",
                                          {"fullName": client_section.full_name,
                                           "copyright": client_section.copyright})
        root.add_child(file_comp)

        file_comp = FileTemplateComponent("setup.py", "../../app/static/setup.py.tmpl",
                                          {"name": client_section.name,
                                           "installRequires": self.create_install_requires(
                                               client_section.install_requires),
                                           "packages": "", "package_data": ""})
        root.add_child(file_comp)

        file_comp = FileTemplateComponent("LICENSE", "../../app/static/LICENSE.tmpl")
        root.add_child(file_comp)

        file_comp = FileTemplateComponent("MANIFEST.in", "../../app/static/MANIFEST.in.tmpl")
        root.add_child(file_comp)

        file_comp = FileTemplateComponent("dist.py", "dist.py.tmpl",
                                          {"name": client_section.name})
        root.add_child(file_comp)
        file_comp = FileTemplateComponent("clean.py", "../../app/static/clean.py.tmpl",
                                          {"name": client_section.name})
        root.add_child(file_comp)
    def _build_docs_directory(self, context, components_dict):
        """
        Builds the "docs" directory components of the output

        :param context: The template context
        :param components_dict: Dictionary containing components by name (and other info)
        :return: The "docs" directory components of the output
        """
        config = context.template.template_config
        client_section = config.client_section
        root = components_dict["root"]

        doc_dir = DirTemplateComponent("doc")
        root.add_child(doc_dir)

        copyright_body = re.sub(r"^Copyright ",
                                "",
                                client_section.copyright,
                                flags=re.IGNORECASE)
        file_comp = FileTemplateComponent(
            "conf.py", "../../app/static/doc/conf.py.tmpl", {
                "copyright": copyright_body,
                "fullName": client_section.full_name,
                "name": client_section.name
            })
        doc_dir.add_child(file_comp)

        file_comp = FileTemplateComponent(
            "docutils.conf", "../../app/static/doc/docutils.conf.tmpl")
        doc_dir.add_child(file_comp)

        sdk_dir = DirTemplateComponent("sdk")
        doc_dir.add_child(sdk_dir)

        file_comp = FileTemplateComponent(
            "index.rst", "doc/sdk/index.rst.tmpl", {
                "fullName":
                client_section.full_name,
                "fullNameSep":
                self.create_underline(len(client_section.full_name), "="),
                "name":
                client_section.name
            })
        sdk_dir.add_child(file_comp)

        file_comp = FileTemplateComponent(
            "README.html", "../../app/static/doc/sdk/README.html.tmpl", {
                "copyright": client_section.copyright,
                "fullName": client_section.full_name
            })
        sdk_dir.add_child(file_comp)

        file_comp = FileTemplateComponent(
            "overview.rst", "../../app/static/doc/sdk/overview.rst.tmpl")
        sdk_dir.add_child(file_comp)

        file_comp = FileTemplateComponent(
            "installation.rst", "doc/sdk/installation.rst.tmpl", {
                "name":
                client_section.name,
                "pythonVersion":
                self.create_installation_doc_version_text(
                    client_section.language_version),
                "versionTag":
                self.create_dist_version_tag(client_section.language_version)
            })
        sdk_dir.add_child(file_comp)

        file_comp = FileTemplateComponent(
            "sampleconfig.rst",
            "../../app/static/doc/sdk/sampleconfig.rst.tmpl",
            {"fullName": client_section.full_name})
        sdk_dir.add_child(file_comp)
示例#13
0
    def _build_root_directory(self, context, components_dict):
        """
        Builds the "root" directory components of the output

        :param context: The template context
        :param components_dict: Dictionary containing components by name (and other info)
        :return: The "root" directory components of the output
        """
        config = context.template.template_config
        app_section = config.application_section

        root = DirTemplateComponent("")
        components_dict["root"] = root

        file_comp = FileTemplateComponent(
            "README", "README.tmpl", {
                "fullName":
                app_section.full_name,
                "fullNameSep":
                self.create_underline(len(app_section.full_name), "="),
                "copyright":
                app_section.copyright
            })
        root.add_child(file_comp)

        file_comp = FileTemplateComponent("README.md", "README.md.tmpl", {
            "fullName": app_section.full_name,
            "copyright": app_section.copyright
        })
        root.add_child(file_comp)

        file_comp = FileTemplateComponent(
            "setup.py", "setup.py.tmpl", {
                "name":
                app_section.name,
                "installRequires":
                self.create_install_requires(app_section.install_requires),
                "pythonRequires":
                self.create_language_requires(app_section.language_version),
                "packages":
                ',\n        "' + app_section.name + '._config.app"',
                "package_data":
                ',\n        "' + app_section.name + "._config.app\" : ['*']",
                "classifiers":
                self.create_classifiers(app_section.language_version)
            })
        root.add_child(file_comp)

        file_comp = FileTemplateComponent("LICENSE", "LICENSE.tmpl")
        root.add_child(file_comp)

        file_comp = FileTemplateComponent("MANIFEST.in", "MANIFEST.in.tmpl")
        root.add_child(file_comp)

        file_comp = FileTemplateComponent(
            "dist.py", "dist.py.tmpl", {
                "name":
                app_section.name,
                "versionTag":
                self.create_dist_version_tag(app_section.language_version)
            })
        root.add_child(file_comp)

        file_comp = FileTemplateComponent("clean.py", "clean.py.tmpl",
                                          {"name": app_section.name})
        root.add_child(file_comp)

        file_comp = FileTemplateComponent(
            "Dockerfile", "Dockerfile.tmpl", {
                "name":
                app_section.name,
                "pythonVersion":
                self.create_docker_image_language_version(
                    app_section.language_version)
            })
        root.add_child(file_comp)