reformat to match webfishing-sync-tool

This commit is contained in:
Obie Hinojosa 2025-05-28 16:34:43 -05:00
parent 246963b004
commit fe93176c37

View File

@ -1,33 +1,78 @@
# compiling this is easy, just run `pip install wget` and `pip install pyinstaller` and then...
# -----------------------read me?---------------------------
# compiling this is super easy, just run `pip install wget` and `pip install pyinstaller` and then
# compile with `python -m PyInstaller --onefile installer.py --icon image.ico`
# (wget is a dependency for this python script that doesnt come with python by default)
# (and pyinstaller is the packagey thingamajig that compiles the code into an executable.)
# also, peep the organized code blocks!! am i cool or what?
# something worthy of note: this code desperately needs to be refactored. right now literally
# everything important happens under a big if elif statement and its pretty fucking stupid
# -----------------import dependencies----------------------
import wget; import os; import platform; import time
import shutil; import tarfile
#import dependencies
import wget
import tarfile
import os
import platform
import time
import shutil
from pathlib import Path
#define some functions ahead of time
def delete_directory(directory):
try:
shutil.rmtree(str(directory))
except OSError as e:
print("Error: %s - %s." % (e.filename, e.strerror))
#this defines a function to delete a directory (no shit)
def extract_tar_archive(tar_file_path, extract_to):
# -----------define some functions ahead of time------------
# idea! consolidate both delete things and add an extra option to the functions that toggles-
# -error outputs using an if statement in the function's code `if quiet = true then... else...`
# as far as i can tell, i wanted to add an "option" to the function that toggled the warning m-
# -essage, so i dont have to use all this space here defining functions i dont really need.
def delete_directory_warn(directory_to_delete, warn=False):
#this defines a function to delete a directory (no shit)
try:
shutil.rmtree(str(directory_to_delete))
except OSError as e:
print("[ERR!]: %s - %s." % (e.filename, e.strerror))
def delete_file_warn(file_to_delete):
#this defines a function to delete a file (no shit)
try:
os.remove(str(file_to_delete))
except OSError as e:
print("[ERR!]: %s - %s." % (e.filename, e.strerror))
def delete_directory(directory_to_delete):
#this defines a function to delete a directory (without any warnings)
try:
shutil.rmtree(str(directory_to_delete))
except:
pass
def delete_file(file_to_delete):
#this defines a function to delete a file (without any warnings)
try:
os.remove(str(file_to_delete))
except:
pass
def compress_tar(folder_path, output_file):
#this defines a function to compress a folder into a tarball
with tarfile.open(output_file, "w:gz") as tar:
tar.add(folder_path, arcname=os.path.basename(folder_path))
#gemini lowkey slayed w this one
def extract_tar(tar_file_path, extract_to):
#this defines a function to decompress a tar.gz file
with tarfile.open(tar_file_path, 'r') as tar:
tar.extractall(extract_to)
#this defines a function to decompress a tar.gz file
def ascii_art():
def print_ascii_art():
#someone's gonna think im a furry or a femboy or some shit because of this.
print()
print()
print(" :+++++=")
@ -64,37 +109,15 @@ def ascii_art():
print(" --::.--")
print(" ....")
print()
#someone's gonna think im a furry or a femboy or some shit because of this.
def win_check_folder_exists(folder):
dir = os.path.normpath(str(Path.cwd()) + "/" + str(folder))
# fuck you microsoft
# this is some high-tier BULLSHIT right here
#print(dir)
if not os.path.exists(dir):
print()
print("[WARN!]: Mod folder not found. (is Fabric installed?)")
print("[WARN!]: (note: the script will go on as usual without breaking anything, but if")
print("[WARN!]: you don't have fabric installed, your mods won't load when you start the game.)")
os.mkdir("mods")
print()
time.sleep(20)
#checks for mod folder existence and outputs [WARN!]
def check_for_old_mod_archive(filepath):
def checkfor_and_delete_file(filepath):
#deletes old downloaded mod archives
if os.path.exists(filepath):
print("Found previously downloaded archive, deleting... Done.")
#shut up
print("Found previously downloaded archive, deleting...")
os.remove(filepath)
#deletes old downloaded mod archives
def compress_tar(folder_path, output_file):
with tarfile.open(output_file, "w:gz") as tar:
tar.add(folder_path, arcname=os.path.basename(folder_path))
#thank you google gemini you are a literal lifesaver
# --------------------the real shit!------------------------
#detect operating system and find home, minecraft, & mod folders
@ -136,8 +159,6 @@ os.chdir(mcfolder)
time.sleep(2)
# unclear if this timeout is necessary for UX
#clear out preexisting mods
check_for_old_mod_archive("mods.tar.gz")
delete_directory("mods")
@ -150,17 +171,21 @@ os.mkdir(str("mods"))
# download mod archive from https://git.adolin.xyz/saru and extract
print("Fetching mods...")
wget.download('https://git.adolin.xyz/saru/lobotomy-mod-pack/raw/branch/main/mods.tar.gz')
# #this is the SIMPLEST implementation of curl i have ever seen i just NUTTED SO FUCKING HARD
# take the last one back, this is fucking insane. `wget` the fucking goat. who knew windows package manager was so damn cool?
wget.download('')
# #this is the SIMPLEST implementation of curl i have ever seen i just NUTTED SO HARD
# take the last one back, this is fucking insane. `wget` the fucking goat. who knew windows package manager was so cool?
extract_tar_archive('mods.tar.gz', 'mods')
# ('tarfile', 'directory to extract to')
ascii_art()
#call func to print ascii art to console
#print boykisser to console
print("sigma!")
print("all done!")
print("This window will exit and close in ten seconds. :)")
time.sleep(10)
time.sleep(10)
# --------------------the real shit!------------------------