Jump to content

Idk, some script to get raw ("Official Unpacked Updates") clients ready for packing


Recommended Posts

  • Contributor

Good evening, fellow citizens of the forum,

 

This is a script that automatically moves and creates folders for the official clients posted in "Official Unpacked Updates", getting them ready for packing.

 

 

Video:

Good luck,

- Amun

 

Update: Lol, I forgot to add the code xD

Spoiler
from os import listdir, mkdir
from os.path import exists, join, isdir
from shutil import move

raw = "raw"
target = "processed"

def MoveFolders():
    if not exists(target):
        mkdir(target)

    for folder in listdir(raw):
        _from = join(raw, folder)

        if not isdir(_from) or folder == "root" or folder == "uiscript":
            print("Skipping {}".format(_from))
            continue

        if folder == "d_" or folder == "ymir work":
            MoveYmirFolders(folder)
            continue

        if folder == "locale" or folder == "locales":#Astro using locales
            MoveLocale(folder)
            continue

        _base = join(target, folder)
        _to = join(_base, folder)

        if not exists(_base):
            mkdir(_base)

        move(_from, _to)
        print("Moved folder {}".format(folder))


def MoveYmirFolders(name):
    if name == "d_":
        ymir = join(raw, name, "ymir work")#astro
    else:
        ymir = join(raw, "ymir work")#p3ng3r

    for folder in listdir(ymir):
        _base = join(target, folder)
        if not exists(_base):
            mkdir(_base)
        
        _work = join(_base, "ymir work")
        if not exists(_work):
            mkdir(_work)

        _from = join(ymir, folder)
        _to = join(_work, folder)

        move(_from, _to)
        print("Moved folder {}".format(folder))


def MoveLocale(locale):
    root = join(raw, locale)

    if locale == "locale":#P3ng3r
        for folder in listdir(root):
            _base = join(target, locale + "_" + folder)
            _from = join(raw, locale, folder)
            _to = join(_base, locale, folder)

            if not exists(_base):
                mkdir(_base)
                mkdir(join(_base, locale))

            move(_from, _to)
            print("Moving locale {}", folder)

    elif locale == "locales":#Astro
        for folder in listdir(root):
            move(join(root, folder), join(target, folder))


__name__ = MoveFolders()

 

 

Edited by Amun
Forgot to add the code xD
  • Metin2 Dev 2
  • Lmao 1
  • Good 3
  • Love 1
Link to comment
Share on other sites

  • Contributor
2 hours ago, hachiwari said:

I dont know python, how will function 'move' behave with duplicates? (we know, sometimes ymir added corrected files wiht update)

Don't know, I didn't think that far.

I just made this shit for getting the entire pack ready for packing. I don't make granular updates, I'm just downloading the entire client, pack it, and bye(hence, the script).

 

Feel free to test/extend it to your needs.

 

Update: It'll replace the file with the new one.

https://docs.python.org/3/library/shutil.html#shutil.move

 

Update2: If you want granular updates, just add a function that recursively checks against your current pack folder using exists(path)

 

Update3: Here, I've done it for you

from os import listdir
from os.path import exists, join, isdir

#CONFIGS
target_folder = "processed_from_raw_pack"
pack_folder = "pack"#check against it recursively to see what's new in the target_folder

f = open("diff.txt", "w")
missing_files = ["MISSING_FILES\n"]
can_add_section_separator = False

def CheckAgainstOldPack(current_path = []):
    global can_add_section_separator

    for file in listdir(join(target_folder, *current_path)):
        current_path.append(file)
        _file_in_old_pack = join(pack_folder, *current_path)

        if isdir(_file_in_old_pack):
            CheckAgainstOldPack(current_path)
            current_path.pop(-1)
            continue

        if not exists(_file_in_old_pack):
            try:# Some files have fucked up names
                print("MISSING ", _file_in_old_pack)
                missing_files.append(_file_in_old_pack+"\n")
                can_add_section_separator = True
            except:
                pass

        current_path.pop(-1)

    if can_add_section_separator:#only add after each section of files, to simbolise different folders
        missing_files.append("\n")
        can_add_section_separator = False

CheckAgainstOldPack()

f.writelines(missing_files)
f.close()

Video:

 

Edit it to remove the files if you need to. You can also timestamp the diffs and use them to reverse one of your updates as well(if needed), just read the list and remove the file, ez.

 

Edited by Amun
Details about granular updates
  • Good 1
Link to comment
Share on other sites

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.