Added my internal tools

This commit is contained in:
James Clarke 2024-01-08 11:11:45 +00:00 committed by the-real-herowl
parent 1b7cde697a
commit 59ffda6e86
4 changed files with 92 additions and 1 deletions

View File

@ -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,glowstone.png,/textures,mcl_nether_glowstone.png,,,,,,,
/assets/minecraft/textures/block,magma.png,/textures,mcl_nether_magma.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/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,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/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,,,,,,, /assets/minecraft/textures/item,nether_wart.png,/textures,mcl_nether_nether_wart.png,,,,,,,

1 Source path Source file Target path Target file xs ys xl yl xt yt Blacklisted?
502 /assets/minecraft/textures/block glowstone.png /textures mcl_nether_glowstone.png
503 /assets/minecraft/textures/block magma.png /textures mcl_nether_magma.png
504 /assets/minecraft/textures/block nether_bricks.png /textures mcl_nether_nether_brick.png
505 /assets/minecraft/textures/item nether_bricks.png nether_brick.png /textures mcl_nether_netherbrick.png
506 /assets/minecraft/textures/block netherrack.png /textures mcl_nether_netherrack.png
507 /assets/minecraft/textures/block nether_wart_block.png /textures mcl_nether_nether_wart_block.png
508 /assets/minecraft/textures/item nether_wart.png /textures mcl_nether_nether_wart.png

View File

@ -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()

View File

@ -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()

View File

@ -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()