# Path: reggata/helpers.py
# def is_none_or_empty(s):
#     '''
#         Returns True, if given string s is None or "" (empty string).
#     If s is and instance of class different from str, function raises TypeError.
#     '''
#     if s is None:
#         return True
#     else:
#         if not isinstance(s, str):
#             raise TypeError("is_none_or_empty() can be applied only to str objects.")
#         return True if s == "" else False
# 
# Path: reggata/data/commands.py
# class GetNamesOfAllTagsAndFields(AbstractCommand):
#     def _execute(self, uow):
#         self._session = uow.session
#         return self.__getNamesOfAllTagsAndFields()
# 
#     def __getNamesOfAllTagsAndFields(self):
#         sql = '''
#         select distinct name from tags
#         UNION
#         select distinct name from fields
#         ORDER BY name
#         '''
#         try:
#             return self._session.query("name").from_statement(sql).all()
#         except ResourceClosedError:
#             return []


import os
import logging
import PyQt4.QtGui as QtGui
import PyQt4.QtCore as QtCore
import reggata.parsers as parsers
import reggata.consts as consts
from PyQt4.QtCore import Qt
from reggata.helpers import is_none_or_empty
from reggata.data.commands import GetNamesOfAllTagsAndFields
            self.setFixedHeight(QtGui.QLineEdit().sizeHint().height())



    def set_completer(self, completer):
        self.completer = completer

    def text(self):
        '''
            This is for QLineEdit behaviour.
        '''
        return self.toPlainText()

    def show_completer(self):
        if self.completer is not None:
            rect = self.cursorRect()
            point = rect.bottomLeft()
            self.completer.move(self.mapToGlobal(point))

            self.completer.end_str = self.completer_end_str


            self.completer.show()
            self.completer.setFocus(Qt.PopupFocusReason)


    def keyPressEvent(self, event):
        cursor = self.textCursor()
        cursor.select(QtGui.QTextCursor.WordUnderCursor)
        word = cursor.selectedText()

# Path: reggata/helpers.py
# def is_none_or_empty(s):
#     '''
#         Returns True, if given string s is None or "" (empty string).
#     If s is and instance of class different from str, function raises TypeError.
#     '''
#     if s is None:
#         return True
#     else:
#         if not isinstance(s, str):
#             raise TypeError("is_none_or_empty() can be applied only to str objects.")
#         return True if s == "" else False
# 
# Path: reggata/data/commands.py
# class GetNamesOfAllTagsAndFields(AbstractCommand):
#     def _execute(self, uow):
#         self._session = uow.session
#         return self.__getNamesOfAllTagsAndFields()
# 
#     def __getNamesOfAllTagsAndFields(self):
#         sql = '''
#         select distinct name from tags
#         UNION
#         select distinct name from fields
#         ORDER BY name
#         '''
#         try:
#             return self._session.query("name").from_statement(sql).all()
#         except ResourceClosedError:
#             return []


# Path: reggata/gui/common_widgets.py
import os
import logging
import PyQt4.QtGui as QtGui
import PyQt4.QtCore as QtCore
import reggata.parsers as parsers
import reggata.consts as consts
from PyQt4.QtCore import Qt
from reggata.helpers import is_none_or_empty
from reggata.data.commands import GetNamesOfAllTagsAndFields

            self.setFixedHeight(QtGui.QLineEdit().sizeHint().height())



    def set_completer(self, completer):
        self.completer = completer

    def text(self):
        '''
            This is for QLineEdit behaviour.
        '''
        return self.toPlainText()

    def show_completer(self):
        if self.completer is not None:
            rect = self.cursorRect()
            point = rect.bottomLeft()
            self.completer.move(self.mapToGlobal(point))

            self.completer.end_str = self.completer_end_str


            self.completer.show()
            self.completer.setFocus(Qt.PopupFocusReason)


    def keyPressEvent(self, event):
        cursor = self.textCursor()
        cursor.select(QtGui.QTextCursor.WordUnderCursor)
        word = cursor.selectedText()

        word = word if not is_none_or_empty(word) else ""