From 768befec89f769dc8883500c4df890952647e330 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Thu, 25 Apr 2024 10:53:29 -0700 Subject: [PATCH] Remove patch renaming scripts These are pretty specific to tasks that kenny and I were doing when they were written, no need to keep them around when they aren't useful for others. --- main.py | 36 ------------------------------------ scripts/moveback.py | 44 -------------------------------------------- 2 files changed, 80 deletions(-) delete mode 100644 main.py delete mode 100644 scripts/moveback.py diff --git a/main.py b/main.py deleted file mode 100644 index b237d452bb..0000000000 --- a/main.py +++ /dev/null @@ -1,36 +0,0 @@ -import os -import re - -# Set the directory where the files are located -dir_path = '/Users/jason/IdeaProjects/PaperMC/Paper/patches/unapplied/server' - -# Change to the directory -os.chdir(dir_path) - -# Regex pattern to match the file names -pattern = r'^(\d+)-(.*\.patch)$' - -# List of files in the directory -files = os.listdir(dir_path) - -# Sort the files numerically -files.sort(key=lambda x: int(re.match(pattern, x).group(1))) - -for file in files: - # Match the file name against the pattern - match = re.match(pattern, file) - if match: - # Extract the current number and description - current_number = int(match.group(1)) - description = match.group(2) - - # Calculate the new number - new_number = current_number + 1 - - # Construct the new file name - new_file_name = f'{str(new_number).zfill(4)}-{description}' - - # Rename the file - os.rename(file, new_file_name) - -print('Files renamed successfully.') diff --git a/scripts/moveback.py b/scripts/moveback.py deleted file mode 100644 index 509e29fab5..0000000000 --- a/scripts/moveback.py +++ /dev/null @@ -1,44 +0,0 @@ -import os -import sys - -# Use inside of server patch dir -# py ../../scripts/moveback.py '' -patch_target = 990 # TODO: Update this - - -def increment_number(filename): - current_number = int(filename[:4]) - new_number = current_number + 1 - return f"{new_number:04d}-{filename[5:]}" - - -if len(sys.argv) != 2: - print("python moveback.py ''") - sys.exit(1) - -input_string = sys.argv[1].replace(' ', '-').lower() -if len(input_string) < 5: - print("Commit title is too short") - sys.exit(1) - -matching_files = [file for file in os.listdir() if input_string in file.lower()] - -if len(matching_files) == 0: - print("No file found matching the given string") - sys.exit(1) - -matching_file = matching_files[0] -print(f"Found: {matching_file}") - -# Move all files after the target one up -for file in os.listdir(): - num = int(file[:4]) - if num >= patch_target: - new_filename = increment_number(file) - os.rename(file, new_filename) - print(f"Renamed {file} to {new_filename}") - -# Rename the file to the target -new_filename = f"{patch_target:04d}-{matching_file[5:]}" -os.rename(matching_file, new_filename) -print(f"Renamed {matching_file} to {new_filename}")