Beispiel #1
0
def test_align_predefined():
    pbar.update(1)
    return rapidtables.make_table(
        table,
        align=(rapidtables.ALIGN_RIGHT, rapidtables.ALIGN_LEFT,
               rapidtables.ALIGN_LEFT, rapidtables.ALIGN_RIGHT,
               rapidtables.ALIGN_LEFT))
Beispiel #2
0
def history(args):
    print("ARGS : " + str(args))
    # If no arguments typed
    if len(args) == 0:
        print("HOWTO")
    elif str(args[0]) == "list":
        # List history in order
        print("List history")
        with open(CONFIG_PATH + 'alpsh_history.json', 'r') as history_list:
            data = json.load(history_list)
            count = 0
            table = []
            for item in range(len(data["history"])):
                table.append({
                    'Index':
                    str(count),
                    'Command':
                    data['history'][count]['command'],
                    "Timestamp":
                    data['history'][count]['timestamp'],
                    'Success':
                    data['history'][count]['success'],
                    'Ran from directory':
                    data['history'][count]['dir_when_ran']
                })
                count += 1
            tables = make_table(table, tablefmt='md')
            print(tables)
            print()
    elif str(args[0] == "clear"):
        print(
            config.get_setting('text', 'danger') +
            "-=-=-=-=-=-=-=-WARNING-=-=-=-=-=-=-=\n" + COLORS.CLEAR +
            "You are about to remove your command history.\n" +
            "This is generally not necessary and is not recommended to do without reason.\n"
            + config.get_setting('text', 'danger') +
            "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" + COLORS.CLEAR)
        response = input("Are you sure you want to continue? [y/N] ")
        if response == "y":
            # Remove history
            history_listener.create(reset=True)
            print(
                config.get_setting('text', 'warning') + "History cleared!\n" +
                COLORS.CLEAR)
        else:
            # Don't remove history
            print(
                config.get_setting('text', 'warning') + "Aborted!\n" +
                COLORS.CLEAR)

    return SHELL_STATUS_RUN
Beispiel #3
0
def rtm_builder(prefix: str,
                root: str = None,
                sort_key: str = None,
                csv_path: str = None) -> str:
    """Generate a traceability matrix, and output to either stdout or csv.

    Args:
        prefix: The prefix for Doorstop requirements.
        root: The root path to search for Doorstop documents.
        sort_key: If the RTM should be sorted, sort by this key.
            Should be one of 'UID', 'Has Test', 'Tests', or None. Defaults to None.
        csv_path: If the RTM should be written to file, write to this path.
            If omitted, the RTM will be returned. Defaults to None.
    """
    tree = doorstop.build(root=root)
    reqs_doc = tree.find_document(prefix)
    table_data = [{
        "UID":
        str(item),
        "Has Test":
        bool(item.child_links),
        "Need Test":
        bool(item.normative),
        "Tests":
        " ".join([str(child) for child in item.child_links]),
    } for item in reqs_doc.items]

    if sort_key:
        table_data = sorted(table_data, key=lambda x: x[sort_key])

    table = rapidtables.make_table(table_data, tablefmt="md")

    if csv_path:
        with open(csv_path, "w", newline="") as csvfile:
            fieldnames = ["UID", "Has Test", "Need Test", "Tests"]
            writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
            writer.writeheader()
            for row in table_data:
                writer.writerow(row)
        return f"Successfully wrote traceability matrix to {csv_path}"
    else:
        return table
Beispiel #4
0
def print_table(directory):
    table = []
    for link in os.listdir(directory):
        if not link.startswith('.'):
            full_path = directory + "/" + link
            size = os.path.getsize(full_path)
            if os.path.isdir(full_path):
                file_type = "Directory"
            elif os.path.isfile(full_path):
                file_type = "File"
            else:
                file_type = "Unknown"
            table.append({
                'Name': link,
                'Size': utils.convert_byte_size(size),
                "Type": file_type
            })

    tables = make_table(table, tablefmt='md')
    print(tables)
    print()
Beispiel #5
0
def show_table(title, table):
    """Show table nicely."""
    show_title(title)
    for line in make_table(table).split("\n"):
        print("    " + line)
Beispiel #6
0
def test_rapidtables():
    return rapidtables.make_table(table)
Beispiel #7
0
def test_rapidtables():
    pbar.update(1)
    return rapidtables.make_table(table)
Beispiel #8
0
def test_all_fixed():
    pbar.update(1)
    return rapidtables.make_table(table,
                                  align=rapidtables.ALIGN_LEFT,
                                  column_width=(20, 20, 20, 20, 20))
Beispiel #9
0
def test_align_numbers_h_cols_h():
    pbar.update(1)
    return rapidtables.make_table(
        table,
        align=rapidtables.ALIGN_HOMOGENEOUS_NUMBERS_RIGHT,
        column_width=rapidtables.COLUMN_HOMOGENEOUS_WIDTH_CALC)
Beispiel #10
0
def test_align_numbers_h():
    pbar.update(1)
    return rapidtables.make_table(
        table, align=rapidtables.ALIGN_HOMOGENEOUS_NUMBERS_RIGHT)
Beispiel #11
0
def test_fixed_align():
    pbar.update(1)
    return rapidtables.make_table(table, align=rapidtables.ALIGN_LEFT)