コード例 #1
0
    def add_tag(self, tag_to_tests):
        """ Append a tag with associated tests to the list.

        This method associates the internal model data with the GUI. While the
        sort order of the GUI can change at any time, the order of the data in
        the model does not. The entry in the model is referenced by a new id
        generated by wx.NewId(). This prevents overwriting entries when
        combining delete and insert statements.

        Args:
            index: An int marking the position to insert the row at.
            tag_to_tests: A tuple mapping tests(list, index 0) to a
                          tag(str, index 1).

        Returns:
            An int indicating the entry in the model so that it can be
            associated with the sorting algorithm for example.
        """

        model_index = wx.NewId()
        position = self.GetItemCount()
        self._clientData[model_index] = tag_to_tests
        if wx.VERSION >= (3, 0, 3, ''):  # DEBUG wxPhoenix
            self.InsertItem(position, unicode(tag_to_tests[1]))
            self.SetItem(position, 1, str(len(tag_to_tests[0])))
        else:
            self.InsertStringItem(position, unicode(tag_to_tests[1]))
            self.SetStringItem(position, 1, str(len(tag_to_tests[0])))
        # associate the model with the GUI
        self.SetItemData(position, model_index)
        return model_index
コード例 #2
0
ファイル: tagdialogs.py プロジェクト: HelioGuilherme66/RIDE
    def add_tag(self, tag_to_tests):
        """ Append a tag with associated tests to the list.

        This method associates the internal model data with the GUI. While the
        sort order of the GUI can change at any time, the order of the data in
        the model does not. The entry in the model is referenced by a new id
        generated by wx.NewId(). This prevents overwriting entries when
        combining delete and insert statements.

        Args:
            index: An int marking the position to insert the row at.
            tag_to_tests: A tuple mapping tests(list, index 0) to a
                          tag(str, index 1).

        Returns:
            An int indicating the entry in the model so that it can be
            associated with the sorting algorithm for example.
        """

        model_index = wx.NewId()
        position = self.GetItemCount()
        self._clientData[model_index] = tag_to_tests
        if wx.VERSION >= (3, 0, 3, ''):  # DEBUG wxPhoenix
            self.InsertItem(position, unicode(tag_to_tests[1]))
            self.SetItem(position, 1, str(len(tag_to_tests[0])))
        else:
            self.InsertStringItem(position, unicode(tag_to_tests[1]))
            self.SetStringItem(position, 1, str(len(tag_to_tests[0])))
        # associate the model with the GUI
        self.SetItemData(position, model_index)
        return model_index
コード例 #3
0
 def _fetch_lib(self, name, arguments, cursor):
     t = cursor.execute(
         'select max(last_updated) from libraries where name = ? and arguments = ?',
         (name, unicode(arguments))).fetchone()[0]
     return cursor.execute(
         'select * from libraries where name = ? and arguments = ? and last_updated = ?',
         (name, unicode(arguments), t)).fetchone()
コード例 #4
0
 def __call__(self, data):
     from .messages import RideLogException
     try:
         self.listener(data)
     except Exception as err:
         # Prevent infinite recursion if RideLogMessage listener is broken,
         if not isinstance(data, RideLogException):
             RideLogException(message='Error in listener: %s\n' \
                                      'While handling %s' % (unicode(err),
                                                             unicode(data)),
                              exception=err, level='ERROR').publish()
コード例 #5
0
ファイル: publisher.py プロジェクト: HelioGuilherme66/RIDE
 def __call__(self, data):
     from .messages import RideLogException
     try:
         self.listener(data)
     except Exception as err:
         # Prevent infinite recursion if RideLogMessage listener is broken,
         if not isinstance(data, RideLogException):
             RideLogException(message='Error in listener: %s\n' \
                                      'While handling %s' % (unicode(err),
                                                             unicode(data)),
                              exception=err, level='ERROR').publish()
コード例 #6
0
 def item_text(self, row, col):
     test, match = self._tests[row]
     if col == 0:
         return test.name
     if col == 1:
         return u', '.join(unicode(t) for t in test.tags)
     return test.datafile_controller.longname
コード例 #7
0
 def item_text(self, row, col):
     test, match = self._tests[row]
     if col == 0:
         return test.name
     if col == 1:
         return u', '.join(unicode(t) for t in test.tags)
     return test.datafile_controller.longname
コード例 #8
0
ファイル: testrunnerplugin.py プロジェクト: scathaig/RIDE
 def OnRun(self, event):
     """Called when the user clicks the "Run" button"""
     if not self._can_start_running_tests():
         return
     #if no tests are selected warn the user, issue #1622
     if not self.tests_selected():
         if not self.ask_user_to_run_anyway():
             # In Linux NO runs dialog 4 times
             return
     self._initialize_ui_for_running()
     command = self._create_command()
     self._output("command: %s\n" % command)  # DEBUG encode
     try:
         if PY2:
             command = bytes(command)  # .encode(encoding))
             # TODO This does not work if for example -i Áçãú
         # self._output("DEBUG: starting command %s\n" % command)
         # DEBUG encode
         self._test_runner.run_command(
             command, self._get_current_working_dir())
         # self._output("DEBUG: Passed test_runner.run_command\n")
         self._process_timer.Start(41)  # roughly 24fps
         self._set_running()
         self._progress_bar.Start()
     except Exception as e:
         # self._output("DEBUG: Except block test_runner.run_command\n")
         self._set_stopped()
         error, log_message = self.get_current_profile().format_error(
             unicode(e), None)
         self._output(error)
         if log_message:
             log_message.publish()
コード例 #9
0
 def delete(self):
     self.controller.remove(unicode(self.name))
     if type(self) is Tag and len(self.controller._tags.value) == 0:
         if len(self.controller.parent.default_tags.value) > 0:
             self.controller.set_value("")
         else:
             self.controller.clear()
コード例 #10
0
ファイル: testrunnerplugin.py プロジェクト: dadapenga/Ltest
 def OnRun(self, event):
     """Called when the user clicks the "Run" button"""
     if not self._can_start_running_tests():
         return
     #if no tests are selected warn the user, issue #1622
     if not self.tests_selected():
         if not self.ask_user_to_run_anyway():
             # In Linux NO runs dialog 4 times
             return
     self._initialize_ui_for_running()
     command = self._create_command()
     self._output("command: %s\n" % command)  # DEBUG encode
     try:
         if PY2:
             command = bytes(command)  # .encode(encoding))
             # TODO This does not work if for example -i Áçãú
         # self._output("DEBUG: starting command %s\n" % command)
         # DEBUG encode
         self._test_runner.run_command(command,
                                       self._get_current_working_dir())
         # self._output("DEBUG: Passed test_runner.run_command\n")
         self._process_timer.Start(41)  # roughly 24fps
         self._set_running()
         self._progress_bar.Start()
     except Exception as e:
         # self._output("DEBUG: Except block test_runner.run_command\n")
         self._set_stopped()
         error, log_message = self.get_current_profile().format_error(
             unicode(e), None)
         self._output(error)
         if log_message:
             log_message.publish()
コード例 #11
0
ファイル: tags.py プロジェクト: HelioGuilherme66/RIDE
 def delete(self):
     self.controller.remove(unicode(self.name))
     if type(self) is Tag and len(self.controller._tags.value) == 0:
         if len(self.controller.parent.default_tags.value) > 0:
             self.controller.set_value("")
         else:
             self.controller.clear()
コード例 #12
0
 def OnCreateKeyword(self, event):
     cells = self._data_cells_from_current_row()
     if not cells:
         return
     try:
         self._execute(AddKeywordFromCells(cells))
     except ValueError as err:
         wx.MessageBox(unicode(err))
コード例 #13
0
ファイル: kweditor.py プロジェクト: robotframework/RIDE
 def OnCreateKeyword(self, event):
     cells = self._data_cells_from_current_row()
     if not cells:
         return
     try:
         self._execute(AddKeywordFromCells(cells))
     except ValueError as err:
         wx.MessageBox(unicode(err))
コード例 #14
0
 def get_and_insert_keywords(self, library_name, library_args):
     result_queue = Queue.Queue(maxsize=1)
     self._messages.put(
         ('insert', library_name, library_args, result_queue), timeout=3)
     try:
         return result_queue.get(timeout=5)
     except Queue.Empty as e:
         RideLogMessage(u'Failed to read keywords from library db: {}'
                        .format(unicode(e))).publish()
         return []
コード例 #15
0
 def _matches(self, test):
     name = test.name.lower()
     if self._match_in(name):
         return True
     if any(self._match_in(unicode(tag).lower()) for tag in test.tags):
         return True
     doc = test.documentation.value.lower()
     if self._match_in(doc):
         return True
     return False
コード例 #16
0
ファイル: iteminfo.py プロジェクト: HelioGuilherme66/RIDE
 def details(self):
     value = self._value
     if self.name.startswith('@'):
         if value is None:
             value = '[ ]'
     return ('<table>'
             '<tr><td><i>Name:</i></td><td>%s</td></tr>'
             '<tr><td><i>Source:</i></td><td>%s</td></tr>'
             '<tr><td valign=top><i>Value:</i></td><td>%s</td></tr>'
             '</table>') % (self.name, self._original_source, unicode(value))
コード例 #17
0
 def test_finds_newest_version(self):
     self._database.insert_library_keywords(
         'lib.py', 'foo',
         [LibraryKeywordInfo('this is old', 'doc', 'lib.py', '')])
     self._database.insert_library_keywords(
         'lib.py', 'foo',
         [LibraryKeywordInfo('this is new', 'doc', 'lib.py', '')])
     kws = self._database.fetch_library_keywords('lib.py', 'foo')
     self.assertEqual(len(kws), 1, unicode(kws))
     self.assertEqual(kws[0].name, 'this is new')
コード例 #18
0
 def get_and_insert_keywords(self, library_name, library_args):
     result_queue = Queue.Queue(maxsize=1)
     self._messages.put(
         ('insert', library_name, library_args, result_queue), timeout=3)
     try:
         return result_queue.get(timeout=5)
     except Queue.Empty as e:
         RideLogMessage(u'Failed to read keywords from library db: {}'
                        .format(unicode(e))).publish()
         return []
コード例 #19
0
ファイル: searchtests.py プロジェクト: HelioGuilherme66/RIDE
 def _matches(self, test):
     name = test.name.lower()
     if self._match_in(name):
         return True
     if any(self._match_in(unicode(tag).lower()) for tag in test.tags):
         return True
     doc = test.documentation.value.lower()
     if self._match_in(doc):
         return True
     return False
コード例 #20
0
 def _search_for_tags(self):
     unique_tags = _SortableD()  # dict()  # utils.NormalizedDict() # DEBUG
     for i in self.model.suite.children:
         for test in i.testcase_table.tests:
             try:
                 for tag in getattr(test.tags, 'tags').split("    "):
                     if tag is None or len(unicode(tag).strip()) == 0:
                         continue
                     else:
                         tag_name = unicode(tag)
                     if tag_name in unique_tags:
                         unique_tags[tag_name].append(test)
                     else:
                         unique_tags[tag_name] = [test]
             except AttributeError:
                 pass
     isreversed = (self.sort_state[0] == 0 and self.sort_state[1] == 0)
     self._results = sorted(unique_tags.items(),
                            key=lambda item: len(item[0]),
                            reverse=isreversed)
コード例 #21
0
 def details(self):
     value = self._value
     if self.name.startswith('@'):
         if value is None:
             value = '[ ]'
     return ('<table>'
             '<tr><td><i>Name:</i></td><td>%s</td></tr>'
             '<tr><td><i>Source:</i></td><td>%s</td></tr>'
             '<tr><td valign=top><i>Value:</i></td><td>%s</td></tr>'
             '</table>') % (self.name, self._original_source,
                            unicode(value))
コード例 #22
0
def _parse_args(args):
    parsed = []
    if args.positional:
        parsed.extend(list(args.positional))
    if args.defaults:
        for i, value in enumerate(args.defaults):
            index = len(args.positional) - len(args.defaults) + i
            parsed[index] = parsed[index] + '=' + unicode(value)
    if args.varargs:
        parsed.append('*%s' % args.varargs)
    if args.kwargs:
        parsed.append('**%s' % args.kwargs)
    return parsed
コード例 #23
0
ファイル: tagdialogs.py プロジェクト: lf1687/MyTools
    def _search_for_tags(self):
        unique_tags = utils.NormalizedDict()
        self._tags = utils.NormalizedDict()
        self._test_cases = []
        for test in self.frame._controller.all_testcases():
            self._test_cases.append(test)
            for tag in test.tags:
                if tag.is_empty() or len(unicode(tag).strip()) == 0:
                    continue
                else:
                    tag_name = unicode(tag)
                if tag_name in unique_tags:
                    unique_tags[tag_name].append(test)
                    self._tags[tag_name].append(tag)
                else:
                    unique_tags[tag_name] = [test]
                    self._tags[tag_name] = [tag]

        isreversed = (self.sort_state[1] != 1)
        self.total_test_cases = len(self._test_cases)
        self._results = sorted(unique_tags.items(),
                               key=lambda item: item[0].lower,
                               reverse=isreversed)
コード例 #24
0
 def insert_library_keywords(self, library_name, library_arguments,
                             keywords):
     cur = self._cursor()
     old_versions = cur.execute(
         'select id from libraries where name = ? and arguments = ?',
         (library_name, unicode(library_arguments))).fetchall()
     cur.executemany('delete from keywords where library = ?', old_versions)
     cur.executemany('delete from libraries where id = ?', old_versions)
     lib = self._insert_library(library_name, library_arguments, cur)
     keyword_values = [[
         kw.name, kw.doc, u' | '.join(kw.arguments), kw.source, lib[0]
     ] for kw in keywords if kw is not None]
     self._insert_library_keywords(keyword_values, cur)
     self._connection.commit()
コード例 #25
0
    def __init__(self, message, exception, level='INFO', notify_user=False):
        """Initializes a RIDE log exception.

        The log ``level`` has default value ``INFO`` and the ``timestamp``
        is generated automatically. Message is automatically appended with
        a traceback.
        """
        exc_type, exc_value, exc_traceback = sys.exc_info()
        if exc_traceback:
            tb = traceback.extract_tb(exc_traceback)
            message += '\n\nTraceback (most recent call last):\n%s\n%s' % \
                (unicode(exception), ''.join(traceback.format_list(tb)))
        RideMessage.__init__(
            self, message=message, level=level, notify_user=False,
            timestamp=utils.get_timestamp(), exception=exception)
コード例 #26
0
ファイル: tagdialogs.py プロジェクト: HelioGuilherme66/RIDE
    def _search_for_tags(self):
        unique_tags = utils.NormalizedDict()
        self._tags = utils.NormalizedDict()
        self._test_cases = []
        for test in self.frame._controller.all_testcases():
            self._test_cases.append(test)
            for tag in test.tags:
                if tag.is_empty() or len(unicode(tag).strip()) == 0:
                    continue
                else:
                    tag_name = unicode(tag)
                if tag_name in unique_tags:
                    unique_tags[tag_name].append(test)
                    self._tags[tag_name].append(tag)
                else:
                    unique_tags[tag_name] = [test]
                    self._tags[tag_name] = [tag]

        isreversed = (self.sort_state[1] != 1)
        self.total_test_cases = len(self._test_cases)

        self._results = sorted(unique_tags.items(),
                               key=lambda item: item[0].lower(),
                               reverse=isreversed)
コード例 #27
0
    def insert_library_keywords(self, library_name, library_arguments,
                                keywords):
        library_doc_format = "ROBOT"
        if len(keywords) > 0:
            library_doc_format = keywords[0].doc_format
            #if any(x.doc_format != library_doc_format for x in keywords):
            #    print("debug: keywords doc format not consistent within library")

        cur = self._cursor()
        old_versions = cur.execute(
            'select id from libraries where name = ?  and arguments = ?',
            (library_name, unicode(library_arguments))).fetchall()
        cur.executemany('delete from keywords where library = ?', old_versions)
        cur.executemany('delete from libraries where id = ?', old_versions)
        lib = self._insert_library(library_name, library_doc_format,
                                   library_arguments, cur)
        keyword_values = [[
            kw.name, kw.doc, u' | '.join(kw.arguments), kw.source, lib[0]
        ] for kw in keywords if kw is not None]
        self._insert_library_keywords(keyword_values, cur)
        self._connection.commit()
コード例 #28
0
ファイル: iteminfo.py プロジェクト: HelioGuilherme66/RIDE
 def _source_name(self, source):
     return unicode(os.path.basename(source)) if source else ''
コード例 #29
0
 def _tags(self):
     if self.__tags is None:
         self.__tags = [unicode(tag).lower() for tag in self._test.tags]
     return self.__tags
コード例 #30
0
ファイル: searchtests.py プロジェクト: HelioGuilherme66/RIDE
 def matches(self, test):
     tags = [unicode(tag) for tag in test.tags]
     if self._matches(tags):
         return test.longname
     return False
コード例 #31
0
 def matches(self, test):
     tags = [unicode(tag) for tag in test.tags]
     if self._matches(tags):
         return test.longname
     return False
コード例 #32
0
 def _insert_library(self, name, doc_format, arguments, cursor):
     cursor.execute('insert into libraries values (null, ?, ?, ?, ?)',
                    (name, doc_format, unicode(arguments), time.time()))
     return self._fetch_lib(name, arguments, cursor)
コード例 #33
0
 def _key(self, name, args):
     return name, unicode(tuple(args or ''))
コード例 #34
0
ファイル: cache.py プロジェクト: HelioGuilherme66/RIDE
 def _key(self, name, args):
     return name, unicode(tuple(args or ''))
コード例 #35
0
def TipMessage(cell):
    if not cell:
        return ''
    tip = _TooltipMessage(cell) if not cell.for_loop \
        else _ForLoopTooltipMessage(cell)
    return html_escape(unicode(tip))
コード例 #36
0
 def _insert_library(self, name, doc_format, arguments, cursor):
     cursor.execute('insert into libraries values (null, ?, ?, ?, ?)', (name, doc_format, unicode(arguments), time.time()))
     return self._fetch_lib(name, arguments, cursor)
コード例 #37
0
 def update_library_timestamp(self, name, arguments, milliseconds=None):
     self._cursor().execute('update libraries set last_updated = ? where name = ? and arguments = ?', (milliseconds or time.time(), name, unicode(arguments)))
     self._connection.commit()
コード例 #38
0
 def _fetch_lib(self, name, arguments, cursor):
     t = cursor.execute('select max(last_updated) from libraries where name = ?  and arguments = ?', (name, unicode(arguments))).fetchone()[0]
     return cursor.execute('select * from libraries where name = ?  and arguments = ? and last_updated = ?', (name, unicode(arguments), t)).fetchone()
コード例 #39
0
    def insert_library_keywords(self, library_name, library_arguments, keywords):
        library_doc_format = "ROBOT"
        if len(keywords) > 0:
            library_doc_format = keywords[0].doc_format
            #if any(x.doc_format != library_doc_format for x in keywords):
            #    print("debug: keywords doc format not consistent within library")

        cur = self._cursor()
        old_versions = cur.execute('select id from libraries where name = ?  and arguments = ?', (library_name, unicode(library_arguments))).fetchall()
        cur.executemany('delete from keywords where library = ?', old_versions)
        cur.executemany('delete from libraries where id = ?', old_versions)
        lib = self._insert_library(library_name, library_doc_format, library_arguments, cur)
        keyword_values = [[kw.name, kw.doc, u' | '.join(kw.arguments), kw.source, lib[0]] for kw in keywords if kw is not None]
        self._insert_library_keywords(keyword_values, cur)
        self._connection.commit()
コード例 #40
0
 def _source(self, item):
     return unicode(os.path.basename(item.source)) if item.source else ''
コード例 #41
0
ファイル: variablefetcher.py プロジェクト: lf1687/MyTools
def _format_value(value):
    if isinstance(value, basestring):
        return value
    if isinstance(value, list):
        return u'[ %s ]' % u' | '.join(unicode(v) for v in value)
    return unicode(value)
コード例 #42
0
def _format_value(value):
    if isinstance(value, basestring):
        return value
    if isinstance(value, list):
        return u'[ %s ]' % u' | '.join(unicode(v) for v in value)
    return unicode(value)
コード例 #43
0
ファイル: iteminfo.py プロジェクト: HelioGuilherme66/RIDE
 def _source(self, item):
     return unicode(os.path.basename(item.source)) if item.source else ''
コード例 #44
0
 def _cache_error(self, data, error):
     self._errors.append("Error in serializing '%s':\n%s"
                         % (data.data.source, unicode(error)))
コード例 #45
0
 def update_library_timestamp(self, name, arguments, milliseconds=None):
     self._cursor().execute(
         'update libraries set last_updated = ? where name = ? and arguments = ?',
         (milliseconds or time.time(), name, unicode(arguments)))
     self._connection.commit()
コード例 #46
0
ファイル: searchtests.py プロジェクト: HelioGuilherme66/RIDE
 def _tags(self):
     if self.__tags is None:
         self.__tags = [unicode(tag).lower() for tag in self._test.tags]
     return self.__tags
コード例 #47
0
 def _source_name(self, source):
     return unicode(os.path.basename(source)) if source else ''
コード例 #48
0
ファイル: project.py プロジェクト: scathaig/RIDE
 def _cache_error(self, data, error):
     self._errors.append("Error in serializing '%s':\n%s"
                         % (data.data.source, unicode(error)))