コード例 #1
0
 def do_checksum(self):
     path_to_checksum = os.fspath(config_vars["__MAIN_INPUT_FILE__"])
     ignore_files = list(config_vars.get("WTAR_IGNORE_FILES", []))
     checksums_dict = utils.get_recursive_checksums(path_to_checksum, ignore=ignore_files)
     total_checksum = checksums_dict.pop('total_checksum', "Unknown total checksum")
     path_and_checksum_list = [(path, checksum) for path, checksum in sorted(checksums_dict.items())]
     width_list, align_list = utils.max_widths(path_and_checksum_list)
     col_formats = utils.gen_col_format(width_list, align_list)
     for p_and_c in path_and_checksum_list:
         print(col_formats[len(p_and_c)].format(*p_and_c))
     print()
     print(col_formats[2].format("total checksum", total_checksum))
コード例 #2
0
ファイル: instlMisc.py プロジェクト: wavesaudio/instl
 def do_checksum(self):
     path_to_checksum = var_stack.ResolveVarToStr("__MAIN_INPUT_FILE__")
     ignore_files = var_stack.ResolveVarToList("WTAR_IGNORE_FILES", default=list())
     checksums_dict = utils.get_recursive_checksums(path_to_checksum, ignore=ignore_files)
     total_checksum = checksums_dict.pop('total_checksum', "Unknown total checksum")
     path_and_checksum_list = [(path, checksum) for path, checksum in sorted(checksums_dict.items())]
     width_list, align_list = utils.max_widths(path_and_checksum_list)
     col_formats = utils.gen_col_format(width_list, align_list)
     for p_and_c in path_and_checksum_list:
         print(col_formats[len(p_and_c)].format(*p_and_c))
     print()
     print(col_formats[2].format("total checksum", total_checksum))
コード例 #3
0
ファイル: ls.py プロジェクト: shaishasag/instl
def list_of_dicts_describing_disk_items_to_text_lines(items_list, ls_format):
    # when calculating widths - avoid comment lines
    real_line_list = list()  # lines that are not empty or comments
    # when printing - avoid formatting of comment lines or empty lines (empty lines might be created by weird ls_format)
    for item_dict in items_list:
        if item_dict:
            real_line_list.append(item_dict_to_list(item_dict, ls_format))
    width_list, align_list = utils.max_widths(real_line_list)
    col_formats = utils.gen_col_format(width_list, align_list)
    formatted_lines = list()
    for ls_line in real_line_list:
        formatted_lines.append(col_formats[len(ls_line)].format(*ls_line))
    return formatted_lines
コード例 #4
0
    def defaults_help(self):
        defaults_folder_path = os.path.join(var_stack.ResolveVarToStr("__INSTL_DATA_FOLDER__"), "defaults")
        for yaml_file in os.listdir(defaults_folder_path):
            if fnmatch.fnmatch(yaml_file, '*.yaml') and yaml_file != "P4.yaml":  # hack to not read the P4 defaults
                self.instlObj.read_yaml_file(os.path.join(defaults_folder_path, yaml_file))
        defaults_list = [("Variable name", "Raw value", "Resolved value"),
                         ("_____________", "_________", "______________")]
        for var in sorted(var_stack):
            if not var.startswith("__"):
                cv = var_stack.get_configVar_obj(var)
                raw_value = " ".join([value for value in cv])
                resolved_value = var_stack.ResolveVarToStr(var)
                if raw_value != resolved_value:
                    defaults_list.append((var, raw_value, resolved_value))
                else:
                    defaults_list.append((var, raw_value))

        col_format = utils.gen_col_format(utils.max_widths(defaults_list))
        for res_line in defaults_list:
            print(col_format[len(res_line)].format(*res_line))
コード例 #5
0
    def defaults_help(self, var_name=None):
        defaults_folder_path = config_vars["__INSTL_DEFAULTS_FOLDER__"].Path()
        for yaml_file in os.listdir(defaults_folder_path):
            if fnmatch.fnmatch(yaml_file, '*.yaml') and yaml_file != "P4.yaml":  # hack to not read the P4 defaults
                self.instlObj.read_yaml_file(defaults_folder_path.joinpath(yaml_file))
        defaults_list = [("Variable name", "Raw value", "Resolved value"),
                         ("_____________", "_________", "______________")]
        for var in sorted(config_vars.keys()):
            if not var.startswith("__"):
                raw_value = config_vars[var].raw(join_sep=" ")
                resolved_value = str(config_vars[var])
                if raw_value != resolved_value:
                    defaults_list.append((var, raw_value, resolved_value))
                else:
                    defaults_list.append((var, raw_value))

        width_list, align_list = utils.max_widths(defaults_list)
        col_format = utils.gen_col_format(width_list, align_list)
        for res_line in defaults_list:
            a_line = col_format[len(res_line)].format(*res_line)
            print(a_line)