Esempio n. 1
0
    def run(self):
        """Run method that performs all the real work"""
        # create and show the dialog
        self.dialog = PluginBuilderDialog()

        # get version
        cfg = ConfigParser.ConfigParser()
        cfg.read(os.path.join(self.plugin_builder_path, 'metadata.txt'))
        version = cfg.get('general', 'version')
        self.dialog.setWindowTitle('QGIS Plugin Builder - {}'.format(version))

        # connect the ok button to our method
        self.dialog.button_box.accepted.connect(self.validate_entries)
        self.dialog.button_box.helpRequested.connect(self.show_help)

        # show the dialog
        self.dialog.show()
        result = self.dialog.exec_()
        if result == QFileDialog.Rejected:
            return

        specification = PluginSpecification(self.dialog)
        # get the location for the plugin
        # noinspection PyCallByClass,PyTypeChecker
        self.plugin_path = QFileDialog.getExistingDirectory(
            self.dialog, 'Select the Directory for your Plugin', self._last_used_path())
        if self.plugin_path == '':
            return
        else:
            if not self._get_plugin_path():
                return False

        self._set_last_used_path(self.plugin_path)
        template_dir = self._create_plugin_directory()
        self._prepare_code(specification, template_dir)
        self._prepare_help(template_dir)
        self._prepare_tests(specification)

        self._prepare_scripts()

        #resource = QFile(os.path.join(template_dir, 'resources.qrc'))
        #resource.copy(os.path.join(self.plugin_path, 'resources.qrc'))

        results_popped, template_module_name = self._prepare_results_html(
            specification)

        self._prepare_readme(specification, template_module_name)
        self._prepare_metadata(specification)
        # show the results
        results_dialog = ResultDialog()
        results_dialog.web_view.setHtml(results_popped)
        results_dialog.show()
        results_dialog.exec_()
    def run(self):
        """Run method that performs all the real work"""
        # create and show the dialog
        self.dialog = PluginBuilderDialog(
            stored_output_path=self._last_used_path())

        # get version
        cfg = ConfigParser.ConfigParser()
        cfg.read(os.path.join(self.plugin_builder_path, 'metadata.txt'))
        version = cfg.get('general', 'version')
        self.dialog.setWindowTitle('QGIS Plugin Builder - {}'.format(version))

        # connect the ok button to our method
        self.dialog.button_box.helpRequested.connect(self.show_help)
        self.dialog.select_tags.clicked.connect(self._select_tags)

        # show the dialog
        self.dialog.show()
        self.dialog.adjustSize()
        result = self.dialog.exec_()
        if result == QFileDialog.Rejected:
            return

        specification = PluginSpecification(self.dialog)
        # get the location for the plugin
        # noinspection PyCallByClass,PyTypeChecker
        self.plugin_path = self.dialog.output_directory.text()

        self._set_last_used_path(self.plugin_path)
        self._create_plugin_directory()
        self.template = self.dialog.template()
        self.template_dir = os.path.join(self.template.subdir(), 'template')
        self.shared_dir = os.path.join(str(self.plugin_builder_path),
                                       'plugin_templates', 'shared')

        template_map = self.template.template_map(specification, self.dialog)
        specification.template_map.update(template_map)

        self._prepare_code(specification)
        if specification.gen_help:
            self._prepare_help()
        if specification.gen_tests:
            self._prepare_tests(specification)

        if specification.gen_scripts:
            self._prepare_scripts()

        if specification.gen_i18n:
            self._prepare_i18n()

        #resource = QFile(os.path.join(self.template_dir, 'resources.qrc'))
        #resource.copy(os.path.join(self.plugin_path, 'resources.qrc'))

        self._prepare_specific_files(specification)

        results_popped, template_module_name = self._prepare_results_html(
            specification)

        self._prepare_readme(specification, template_module_name)
        self._prepare_metadata(specification)
        # show the results
        results_dialog = ResultDialog()
        results_dialog.textBrowser.setOpenExternalLinks(True)
        results_dialog.textBrowser.setHtml(results_popped)
        results_dialog.show()
        results_dialog.exec_()