Best Python code snippet using avocado_python
list.py
Source:list.py  
...43        if verbose:44            header = (TERM_SUPPORT.header_str('Type'),45                      TERM_SUPPORT.header_str('Test'),46                      TERM_SUPPORT.header_str('Tag(s)'))47        for line in iter_tabular_output(matrix,48                                        header=header,49                                        strip=True):50            LOG_UI.debug(line)51        if verbose:52            if suite.resolutions:53                resolution_header = (TERM_SUPPORT.header_str('Resolver'),54                                     TERM_SUPPORT.header_str('Reference'),55                                     TERM_SUPPORT.header_str('Info'))56                LOG_UI.info("")57                mapping = {58                  ReferenceResolutionResult.SUCCESS: TERM_SUPPORT.healthy_str,59                  ReferenceResolutionResult.NOTFOUND: TERM_SUPPORT.fail_header_str,60                  ReferenceResolutionResult.ERROR: TERM_SUPPORT.fail_header_str61                }62                resolution_matrix = []63                for r in suite.resolutions:64                    decorator = mapping.get(r.result,65                                            TERM_SUPPORT.warn_header_str)66                    if r.result == ReferenceResolutionResult.SUCCESS:67                        continue68                    resolution_matrix.append((decorator(r.origin),69                                              r.reference,70                                              r.info or ''))71                for line in iter_tabular_output(resolution_matrix,72                                                header=resolution_header,73                                                strip=True):74                    LOG_UI.info(line)75            LOG_UI.info("")76            LOG_UI.info("TEST TYPES SUMMARY")77            LOG_UI.info("==================")78            for key in sorted(suite.stats):79                LOG_UI.info("%s: %s", key, suite.stats[key])80            if suite.tags_stats:81                LOG_UI.info("")82                LOG_UI.info("TEST TAGS SUMMARY")83                LOG_UI.info("=================")84                for key in sorted(suite.tags_stats):85                    LOG_UI.info("%s: %s", key, suite.tags_stats[key])...astring.py
Source:astring.py  
...113            continue114        old_word = tmp_word115        return_str += tmp_word[len(special_code):]116    return return_str117def iter_tabular_output(matrix, header=None):118    """119    Generator for a pretty, aligned string representation of a nxm matrix.120    This representation can be used to print any tabular data, such as121    database results. It works by scanning the lengths of each element122    in each column, and determining the format string dynamically.123    :param matrix: Matrix representation (list with n rows of m elements).124    :param header: Optional tuple or list with header elements to be displayed.125    """126    if type(header) is list:127        header = tuple(header)128    lengths = []129    if header:130        for column in header:131            lengths.append(len(column))132    str_matrix = []133    for row in matrix:134        str_matrix.append([])135        for i, column in enumerate(row):136            column = string_safe_encode(column)137            str_matrix[-1].append(column)138            col_len = len(column.decode("utf-8"))139            try:140                max_len = lengths[i]141                if col_len > max_len:142                    lengths[i] = col_len143            except IndexError:144                lengths.append(col_len)145    if not lengths:     # No items...146        raise StopIteration147    format_string = " ".join(["%-" + str(leng) + "s"148                              for leng in lengths[:-1]] +149                             ["%s"])150    if header:151        out_line = format_string % header152        yield out_line153    for row in str_matrix:154        out_line = format_string % tuple(row)155        yield out_line156def tabular_output(matrix, header=None):157    """158    Pretty, aligned string representation of a nxm matrix.159    This representation can be used to print any tabular data, such as160    database results. It works by scanning the lengths of each element161    in each column, and determining the format string dynamically.162    :param matrix: Matrix representation (list with n rows of m elements).163    :param header: Optional tuple or list with header elements to be displayed.164    :return: String with the tabular output, lines separated by unix line feeds.165    :rtype: str166    """167    return "\n".join(iter_tabular_output(matrix, header))168def string_safe_encode(string):169    """170    People tend to mix unicode streams with encoded strings. This function171    tries to replace any input with a valid utf-8 encoded ascii stream.172    """173    if not isinstance(string, basestring):174        string = str(string)175    try:176        return string.encode("utf-8")177    except UnicodeDecodeError:178        return string.decode("utf-8").encode("utf-8")179def string_to_safe_path(string):180    """181    Convert string to a valid file/dir name....plugins.py
Source:plugins.py  
...54                plugin_matrix.append((plugin.name, plugin.obj.description))55            if not plugin_matrix:56                log.debug("(No active plugin)")57            else:58                for line in astring.iter_tabular_output(plugin_matrix):...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
