当前位置: 首页>>代码示例>>Python>>正文


Python Pireal.get_service方法代码示例

本文整理汇总了Python中src.gui.main_window.Pireal.get_service方法的典型用法代码示例。如果您正苦于以下问题:Python Pireal.get_service方法的具体用法?Python Pireal.get_service怎么用?Python Pireal.get_service使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在src.gui.main_window.Pireal的用法示例。


在下文中一共展示了Pireal.get_service方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: execute_queries

# 需要导入模块: from src.gui.main_window import Pireal [as 别名]
# 或者: from src.gui.main_window.Pireal import get_service [as 别名]
    def execute_queries(self, query=''):
        """ This function executes queries """

        # Hide tooltip if visible
        if QToolTip.isVisible():
            QToolTip.hideText()

        # If text is selected, then this text is the query,
        # otherwise the query is all text that has the editor
        editor_widget = self.currentWidget().get_editor()
        if editor_widget.textCursor().hasSelection():
            query = editor_widget.textCursor().selectedText()
        else:
            query = editor_widget.toPlainText()

        relations = self.currentWidget().relations
        central = Pireal.get_service("central")
        table_widget = central.get_active_db().table_widget

        # Restore
        relations.clear()
        self.currentWidget().clear_results()

        # Parse query
        sc = scanner.Scanner(query)
        lex = lexer.Lexer(sc)
        try:
            par = parser.Parser(lex)
            interpreter = parser.Interpreter(par)
            interpreter.clear()
            interpreter.to_python()
        except Exception as reason:
            pireal = Pireal.get_service("pireal")
            pireal.show_error_message(self.parse_error(reason.__str__()))
            return
        relations.update(table_widget.relations)
        for relation_name, expression in list(interpreter.SCOPE.items()):
            if relation_name in relations:
                QMessageBox.critical(self,
                                     self.tr("Query Error"),
                                     self.tr("<b>{}</b> is a duplicate "
                                             "relation name.<br><br> "
                                             "Please choose a unique name "
                                             "and re-execute the "
                                             "queries.".format(
                                                 relation_name)))
                del interpreter.SCOPE[relation_name]
                return
            try:
                new_relation = eval(expression, {}, relations)

            except Exception as reason:
                pireal = Pireal.get_service("pireal")
                pireal.show_error_message(self.parse_error(reason.__str__()),
                                          syntax_error=False)
                return

            relations[relation_name] = new_relation
            self.__add_table(new_relation, relation_name)
开发者ID:centaurialpha,项目名称:pireal,代码行数:61,代码来源:query_container.py

示例2: execute_queries

# 需要导入模块: from src.gui.main_window import Pireal [as 别名]
# 或者: from src.gui.main_window.Pireal import get_service [as 别名]
 def execute_queries(self):
     # Editor instance
     query_editor = Pireal.get_service("query-editor").editor
     query = query_editor.toPlainText()  # Text
     # Parse query
     expression = parser.convert_to_python(query)
     table_widget = Pireal.get_service("db")
     rel = eval(expression, table_widget.relations)
开发者ID:intermezzo-fr,项目名称:pireal,代码行数:10,代码来源:actions.py

示例3: add_table

# 需要导入模块: from src.gui.main_window import Pireal [as 别名]
# 或者: from src.gui.main_window.Pireal import get_service [as 别名]
 def add_table(self, rela, rname):
     central_widget = Pireal.get_service("central")
     lateral_widget = Pireal.get_service("lateral_widget")
     db = central_widget.get_active_db()
     _view = db.create_table(rela, rname, editable=False)
     table_widget = central_widget.get_active_db().table_widget
     index = table_widget.stacked_result.addWidget(_view)
     table_widget.stacked_result.setCurrentIndex(index)
     lateral_widget.result_list.add_item(
         rname, rela.cardinality(), rela.degree())
     # lateral_widget.result_list.select_last()
     table_widget._tabs.setCurrentIndex(1)
开发者ID:yoshitomimaehara,项目名称:pireal,代码行数:14,代码来源:query_container.py

示例4: new_query

# 需要导入模块: from src.gui.main_window import Pireal [as 别名]
# 或者: from src.gui.main_window.Pireal import get_service [as 别名]
    def new_query(self, filename=''):
        query_widget = Pireal.get_service("query_widget")
        self.addWidget(query_widget)
        if not query_widget.isVisible():
            query_widget.show()
        pireal = Pireal.get_service("pireal")
        pireal.enable_disable_query_actions()
        query_widget.new_query(filename)

        self.connect(query_widget,
                     SIGNAL("currentEditorSaved(QPlainTextEdit)"),
                     self.save_query)
开发者ID:papablopo07,项目名称:pireal,代码行数:14,代码来源:container.py

示例5: new_query

# 需要导入模块: from src.gui.main_window import Pireal [as 别名]
# 或者: from src.gui.main_window.Pireal import get_service [as 别名]
 def new_query(self):
     from src.gui.query_editor import query_widget
     widget = query_widget.QueryWidget()
     pireal = Pireal.get_service("pireal")
     # Load the instance
     Pireal.load_service("query-editor", widget)
     # MdiArea
     mdi = Pireal.get_service("mdi")
     widget.setMinimumSize(mdi.width(), mdi.minimumSizeHint().height())
     mdi.addSubWindow(widget)
     # Enable querie's QAction
     pireal.enable_disable_query_actions()
     widget.show()
开发者ID:intermezzo-fr,项目名称:pireal,代码行数:15,代码来源:actions.py

示例6: clear_results

# 需要导入模块: from src.gui.main_window import Pireal [as 别名]
# 或者: from src.gui.main_window.Pireal import get_service [as 别名]
 def clear_results(self):
     central_widget = Pireal.get_service("central")
     lateral_widget = Pireal.get_service("lateral_widget")
     lateral_widget.result_list.clear_items()
     table_widget = central_widget.get_active_db().table_widget
     i = table_widget.stacked_result.count()
     # i = self._stack_tables.count()
     while i >= 0:
         # widget = self._stack_tables.widget(i)
         widget = table_widget.stacked_result.widget(i)
         # self._stack_tables.removeWidget(widget)
         table_widget.stacked_result.removeWidget(widget)
         if widget is not None:
             widget.deleteLater()
         i -= 1
开发者ID:yoshitomimaehara,项目名称:pireal,代码行数:17,代码来源:query_container.py

示例7: create_data_base

# 需要导入模块: from src.gui.main_window import Pireal [as 别名]
# 或者: from src.gui.main_window.Pireal import get_service [as 别名]
 def create_data_base(self):
     mdi = Pireal.get_service("mdi")
     db_name, ok = QInputDialog.getText(mdi, self.tr("New DB"),
                                        self.tr("Name:"),
                                        text=getpass.getuser())
     if ok:
         from src.gui import table_widget
         db_widget = table_widget.MdiDB()
         db_widget.setWindowTitle(db_name + '.pdb')
         db_widget.setMinimumSize(mdi.width(), mdi.height() / 1.7)
         mdi.addSubWindow(db_widget)
         # Enable QAction's
         pireal = Pireal.get_service("pireal")
         pireal.enable_disable_db_actions()
         db_widget.show()
开发者ID:intermezzo-fr,项目名称:pireal,代码行数:17,代码来源:actions.py

示例8: __on_wizard_finished

# 需要导入模块: from src.gui.main_window import Pireal [as 别名]
# 或者: from src.gui.main_window.Pireal import get_service [as 别名]
    def __on_wizard_finished(self, data, wizard_widget):
        """ This slot execute when wizard to create a database is finished """

        pireal = Pireal.get_service("pireal")
        if not data:
            # If it's canceled, remove wizard widget and return to Start Page
            self.remove_last_widget()
        else:
            # Create a new data base container
            db_container = database_container.DatabaseContainer()
            # Associate the file name with the PFile object
            pfile_object = pfile.File(data['filename'])
            # Associate PFile object with data base container
            # and add widget to stacked
            db_container.pfile = pfile_object
            self.add_widget(db_container)
            # Remove wizard
            self.stacked.removeWidget(wizard_widget)
            # Set window title
            pireal.change_title(file_manager.get_basename(data['filename']))
            # Enable db actions
            pireal.set_enabled_db_actions(True)
            pireal.set_enabled_relation_actions(True)
            self.created = True
            DEBUG("Base de datos creada correctamente: '{}'".format(
                data['filename']))

        # If data or not, show menubar and toolbar again
        pireal.show_hide_menubar()
        pireal.show_hide_toolbar()
开发者ID:centaurialpha,项目名称:pireal,代码行数:32,代码来源:central_widget.py

示例9: add_new_table

# 需要导入模块: from src.gui.main_window import Pireal [as 别名]
# 或者: from src.gui.main_window.Pireal import get_service [as 别名]
    def add_new_table(self, rel, name):
        import itertools

        table = QTableWidget()
        table.setRowCount(0)
        table.setColumnCount(0)

        data = itertools.chain([rel.fields], rel.content)

        for row_data in data:
            row = table.rowCount()
            table.setColumnCount(len(row_data))
            for col, text in enumerate(row_data):
                item = QTableWidgetItem()
                item.setText(text)
                if row == 0:
                    table.setHorizontalHeaderItem(col, item)
                else:
                    table.setItem(row - 1, col, item)
            table.insertRow(row)
        table.removeRow(table.rowCount() - 1)
        self.stacked.addWidget(table)
        self.stacked.setCurrentIndex(self.stacked.count() - 1)
        lateral = Pireal.get_service("lateral")
        lateral.add_item_list([name])
开发者ID:intermezzo-fr,项目名称:pireal,代码行数:27,代码来源:table_widget.py

示例10: execute_queries

# 需要导入模块: from src.gui.main_window import Pireal [as 别名]
# 或者: from src.gui.main_window.Pireal import get_service [as 别名]
    def execute_queries(self):
        import re
        # Editor instance
        editor = self.tab.currentWidget()
        # Text
        text = editor.toPlainText()
        # Ignore comments
        table = Pireal.get_service("container").table_widget
        for line in text.splitlines():
            if line.startswith('--'):
                continue
            parts = line.split('=', 1)
            parts[0] = parts[0].strip()
            if re.match(r'^[_a-zA-Z]+[_a-zA-Z0-9]*$', parts[0]):
                relation_name, line = parts
            else:
                relation_name = 'rel_{}'.format(self.__nrelation)
                self.__nrelation += 1
            try:
                expression = parser.convert_to_python(line.strip())
                rel = eval(expression, table.relations)
            except Exception as reason:

            #try:
            #except Exception as reason:
                QMessageBox.critical(self, self.tr("Error en consulta"),
                                     reason.__str__())
                return
            table.add_new_table(rel, relation_name)
            table.relations[relation_name] = rel
开发者ID:papablopo07,项目名称:pireal,代码行数:32,代码来源:query_widget.py

示例11: _check_count

# 需要导入模块: from src.gui.main_window import Pireal [as 别名]
# 或者: from src.gui.main_window.Pireal import get_service [as 别名]
    def _check_count(self):
        """ Hide dock if count = 0 """

        if self.tab.count() == 0:
            pireal = Pireal.get_service("pireal")
            pireal.enable_disable_query_actions(False)
            self.hide()
开发者ID:papablopo07,项目名称:pireal,代码行数:9,代码来源:query_widget.py

示例12: __hide

# 需要导入模块: from src.gui.main_window import Pireal [as 别名]
# 或者: from src.gui.main_window.Pireal import get_service [as 别名]
 def __hide(self):
     if self.count() == 0:
         self.hide()
         # Disable query actions
         pireal = Pireal.get_service("pireal")
         pireal.set_enabled_query_actions(False)
         pireal.set_enabled_editor_actions(False)
开发者ID:yoshitomimaehara,项目名称:pireal,代码行数:9,代码来源:query_container.py

示例13: add_data_base

# 需要导入模块: from src.gui.main_window import Pireal [as 别名]
# 或者: from src.gui.main_window.Pireal import get_service [as 别名]
    def add_data_base(self, data):
        lateral = Pireal.get_service("lateral")
        rel = None
        for part in data.split('@'):
            for e, line in enumerate(part.splitlines()):
                if e == 0:
                    name = line.split(':')[0]
                    rel = relation.Relation()
                    rel.fields = line.split(':')[-1].split(',')
                else:
                    rel.insert(line.split(','))
            if rel is not None:
                table = Table()
                table.setRowCount(1)
                table.setColumnCount(0)
                self.relations[name] = rel

                for _tuple in rel.content:
                    row = table.rowCount()
                    table.setColumnCount(len(rel.fields))
                    for column, text in enumerate(_tuple):
                        item = Item()
                        item.setText(text)
                        table.setItem(row - 1, column, item)
                    table.insertRow(row)
                table.setHorizontalHeaderLabels(rel.fields)
                self.stacked.addWidget(table)
                table.removeRow(table.rowCount() - 1)
                lateral.add_item_list([name])
开发者ID:papablopo07,项目名称:pireal,代码行数:31,代码来源:table_widget.py

示例14: __open_example

# 需要导入模块: from src.gui.main_window import Pireal [as 别名]
# 或者: from src.gui.main_window.Pireal import get_service [as 别名]
 def __open_example(self):
     central_widget = Pireal.get_service("central")
     db_filename = os.path.join(settings.EXAMPLES, 'database.pdb')
     central_widget.open_database(filename=db_filename, remember=False)
     query_filename = os.path.join(settings.EXAMPLES, 'queries.pqf')
     central_widget.open_query(filename=query_filename, remember=False)
     # Ejecuto las consultas de ejemplo luego de 1.3 segundos
     QTimer.singleShot(1300, central_widget.execute_queries)
开发者ID:yoshitomimaehara,项目名称:pireal,代码行数:10,代码来源:start_page.py

示例15: execute_queries

# 需要导入模块: from src.gui.main_window import Pireal [as 别名]
# 或者: from src.gui.main_window.Pireal import get_service [as 别名]
    def execute_queries(self, query=''):
        """ This function executes queries """

        # If text is selected, then this text is the query,
        # otherwise the query is all text that has the editor
        editor_widget = self.currentWidget().get_editor()
        if editor_widget.textCursor().hasSelection():
            query = "\n".join(
                editor_widget.textCursor().selectedText().splitlines())
        else:
            query = editor_widget.toPlainText()
        relations = self.currentWidget().relations
        central = Pireal.get_service("central")
        table_widget = central.get_active_db().table_widget

        # Restore
        relations.clear()
        self.currentWidget().clear_results()

        editor_widget.show_run_cursor()

        # Parse query
        error = True
        try:
            result = parser.parse(query)
        except MissingQuoteError as reason:
            title = self.tr("Error de Sintáxis")
            text = self.parse_error(str(reason))
        except InvalidSyntaxError as reason:
            title = self.tr("Error de Sintáxis")
            text = self.parse_error(str(reason) + "\n" + self.tr(
                "El error comienza con " + reason.character))
        except DuplicateRelationNameError as reason:
            title = self.tr("Nombre duplicado")
            text = self.tr("Ya existe una relación con el nombre <b>{}</b> :(."
                           "<br><br>Elige otro por favor ;).".format(
                               reason.rname))
        except ConsumeError as reason:
            title = self.tr("Error de Sintáxis")
            text = self.parse_error(str(reason))
        else:
            error = False
        if error:
            QMessageBox.critical(self, title, text)
            return
        relations.update(table_widget.relations)
        for relation_name, expression in result.items():
            try:
                new_relation = eval(expression, {}, relations)
            except Exception as reason:
                QMessageBox.critical(
                    self,
                    self.tr("Error de Consulta"),
                    self.parse_error(str(reason))
                )
                return
            relations[relation_name] = new_relation
            self.__add_table(new_relation, relation_name)
开发者ID:yoshitomimaehara,项目名称:pireal,代码行数:60,代码来源:query_container.py


注:本文中的src.gui.main_window.Pireal.get_service方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。