Created
March 12, 2020 15:49
-
-
Save thurask/6daa44fed3e4c061e6aaa7ad0ff4ac6c to your computer and use it in GitHub Desktop.
Revisions
-
thurask created this gist
Mar 12, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,74 @@ import os TS3HEADER = b'DBPF\x02\x00\x00\x00\x00' TS4HEADER = b'DBPF\x02\x00\x00\x00\x01' def collector(indir=None): if indir is None: indir = os.getcwd() results = [] for root, _, files in os.walk(indir): for filex in files: if filex.endswith(".package"): results.append(os.path.join(root, filex)) return results def unified_opener(infile): with open(infile, "rb") as afile: data = afile.read() return data def bulk_check(infile): indata = unified_opener(infile) is_ts3 = ts3_check(indata) is_posepack = posepack_check(indata) return is_ts3, is_posepack def ts3_check(indata): header = indata[:9] if header == TS3HEADER: is_ts3 = True elif header == TS4HEADER: is_ts3 = False else: is_ts3 = None return is_ts3 def posepack_check(indata): is_posepack = True if b"STBL" in indata else False return is_posepack def dicter(infiles): indict = {infi: bulk_check(infi) for infi in infiles} return indict def denker(indict): all_ts3s = [key for key, val in indict.items() if val[0]] all_replacers = [key for key, val in indict.items() if not val[0] and not val[1]] return all_ts3s, all_replacers def main(): infiles = collector() indict = dicter(infiles) all_ts3s, all_replacers = denker(indict) if all_ts3s: print("TS3 PACKAGE FILES:") for _ in all_ts3s: print(_) if all_replacers: print("POSSIBLE NON-POSE PACK FILES (CHECK S4PE):") for _ in all_replacers: print(_) if __name__ == "__main__": main()