From 59ffda6e86e6853af0edeee7544fe91bd0ce43ac Mon Sep 17 00:00:00 2001 From: James David Clarke Date: Mon, 8 Jan 2024 11:11:45 +0000 Subject: [PATCH] Added my internal tools --- tools/Conversion_Table.csv | 2 +- tools/mytools/new_table_conversion.py | 40 +++++++++++++++++++++++++++ tools/mytools/outstanding_conv.py | 36 ++++++++++++++++++++++++ tools/mytools/remove_null_lines.py | 15 ++++++++++ 4 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 tools/mytools/new_table_conversion.py create mode 100644 tools/mytools/outstanding_conv.py create mode 100644 tools/mytools/remove_null_lines.py diff --git a/tools/Conversion_Table.csv b/tools/Conversion_Table.csv index a6af336ea..005500314 100644 --- a/tools/Conversion_Table.csv +++ b/tools/Conversion_Table.csv @@ -502,7 +502,7 @@ Source path,Source file,Target path,Target file,xs,ys,xl,yl,xt,yt,Blacklisted? /assets/minecraft/textures/block,glowstone.png,/textures,mcl_nether_glowstone.png,,,,,,, /assets/minecraft/textures/block,magma.png,/textures,mcl_nether_magma.png,,,,,,, /assets/minecraft/textures/block,nether_bricks.png,/textures,mcl_nether_nether_brick.png,,,,,,, -/assets/minecraft/textures/item,nether_bricks.png,/textures,mcl_nether_netherbrick.png,,,,,,, +/assets/minecraft/textures/item,nether_brick.png,/textures,mcl_nether_netherbrick.png,,,,,,, /assets/minecraft/textures/block,netherrack.png,/textures,mcl_nether_netherrack.png,,,,,,, /assets/minecraft/textures/block,nether_wart_block.png,/textures,mcl_nether_nether_wart_block.png,,,,,,, /assets/minecraft/textures/item,nether_wart.png,/textures,mcl_nether_nether_wart.png,,,,,,, diff --git a/tools/mytools/new_table_conversion.py b/tools/mytools/new_table_conversion.py new file mode 100644 index 000000000..7084fae6f --- /dev/null +++ b/tools/mytools/new_table_conversion.py @@ -0,0 +1,40 @@ +import csv + +def read_csv(file_path): + with open(file_path, mode='r', encoding='utf-8') as file: + return list(csv.reader(file)) + +def write_csv(file_path, data): + with open(file_path, mode='w', encoding='utf-8', newline='') as file: + writer = csv.writer(file) + writer.writerows(data) + +def merge_tables(original_csv, new_csv): + # Convert the lists to dictionaries for easier manipulation + original_dict = {row[3]: row for row in original_csv} + new_dict = {row[3]: row for row in new_csv} + + # Update or add new entries + for key in new_dict: + original_dict[key] = new_dict[key] + + # Convert the dictionary back to a list + merged_data = list(original_dict.values()) + + return merged_data + +def main(): + original_csv_path = './Conversion_Table.csv' + new_csv_path = './Conversion_Table_New.csv' + + original_csv = read_csv(original_csv_path) + new_csv = read_csv(new_csv_path) + + # Skip the header row in new_csv + merged_data = merge_tables(original_csv, new_csv[1:]) + + write_csv(original_csv_path, merged_data) + print("Conversion tables have been merged and updated successfully.") + +if __name__ == "__main__": + main() diff --git a/tools/mytools/outstanding_conv.py b/tools/mytools/outstanding_conv.py new file mode 100644 index 000000000..b3d928a09 --- /dev/null +++ b/tools/mytools/outstanding_conv.py @@ -0,0 +1,36 @@ +import csv + +def read_missing_textures(file_path): + with open(file_path, 'r') as file: + return [line.strip().split('/')[-1] for line in file.readlines()] + +def read_conversion_table(file_path): + with open(file_path, 'r') as file: + return list(csv.reader(file)) + +def find_outstanding_entries(missing_textures, conversion_table): + outstanding_entries = [] + for row in conversion_table: + if row[1] in missing_textures: + outstanding_entries.append(row) + return outstanding_entries + +def write_outstanding_entries(file_path, outstanding_entries): + with open(file_path, 'w', newline='') as file: + writer = csv.writer(file) + writer.writerows(outstanding_entries) + +def main(): + missing_textures_file = './missing_textures_filtered.txt' + conversion_table_file = './Conversion_Table.csv' + output_file = './Conversion_Table_Outstanding.csv' + + missing_textures = read_missing_textures(missing_textures_file) + conversion_table = read_conversion_table(conversion_table_file) + outstanding_entries = find_outstanding_entries(missing_textures, conversion_table) + + write_outstanding_entries(output_file, outstanding_entries) + print("Outstanding conversion table entries written to:", output_file) + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/tools/mytools/remove_null_lines.py b/tools/mytools/remove_null_lines.py new file mode 100644 index 000000000..d1657b6f4 --- /dev/null +++ b/tools/mytools/remove_null_lines.py @@ -0,0 +1,15 @@ +def remove_null_lines(input_file, output_file): + with open(input_file, 'r') as infile, open(output_file, 'w') as outfile: + for line in infile: + if "NULL" not in line: + outfile.write(line) + +def main(): + input_file = './Conversion_Table.csv' # Replace with your input file path + output_file = './Conversion_Table_New.csv' # Replace with your output file path + + remove_null_lines(input_file, output_file) + print("File processed successfully, NULL lines removed.") + +if __name__ == "__main__": + main()