You've already forked PythonLib
mirror of
https://github.com/lifebottle/PythonLib.git
synced 2026-02-13 15:25:50 -08:00
Formatting changes
This commit is contained in:
43
Tales_Exe.py
43
Tales_Exe.py
@@ -1,15 +1,12 @@
|
||||
import ToolsTOR
|
||||
import ToolsNDX
|
||||
import json
|
||||
import argparse
|
||||
import textwrap
|
||||
import os
|
||||
import io
|
||||
import re
|
||||
import requests
|
||||
import os
|
||||
import subprocess
|
||||
import RepoFunctions
|
||||
|
||||
import GoogleAPI
|
||||
import RepoFunctions
|
||||
import ToolsNDX
|
||||
import ToolsTOR
|
||||
|
||||
repos_infos ={
|
||||
"TOR":
|
||||
@@ -25,24 +22,24 @@ repos_infos ={
|
||||
}
|
||||
|
||||
|
||||
|
||||
SCRIPT_VERSION = "0.0.3"
|
||||
|
||||
|
||||
def generate_xdelta_patch(repo_name, xdelta_name="Tales-Of-Rebirth_Patch_New.xdelta"):
|
||||
|
||||
|
||||
print("Create xdelta patch")
|
||||
original_path = "../Data/{}/Disc/Original/{}.iso".format(repo_name, repo_name)
|
||||
new_path = "../Data/{}/Disc/New/{}.iso".format(repo_name, repo_name)
|
||||
subprocess.run(["xdelta", "-f", "-s", original_path, new_path, xdelta_name])
|
||||
|
||||
|
||||
|
||||
|
||||
def get_directory_path(path):
|
||||
return os.path.dirname(os.path.abspath(path))
|
||||
|
||||
def check_arguments(parser, args):
|
||||
if hasattr(args, "elf_path") and not args.elf_path:
|
||||
args.elf_path = get_directory_path(args.input) + "/SLPS_254.50"
|
||||
|
||||
|
||||
if hasattr(args, "elf_out") and not args.elf_out:
|
||||
args.elf_out = get_directory_path(args.input) + "/NEW_SLPS_254.50"
|
||||
|
||||
@@ -53,6 +50,7 @@ def check_arguments(parser, args):
|
||||
else:
|
||||
args.output = args.input
|
||||
|
||||
|
||||
def get_arguments(argv=None):
|
||||
# Init argument parser
|
||||
parser = argparse.ArgumentParser()
|
||||
@@ -181,6 +179,7 @@ def get_arguments(argv=None):
|
||||
|
||||
return args
|
||||
|
||||
|
||||
def send_xdelta():
|
||||
file_link = GoogleAPI.upload_xdelta(xdelta_name, "Stewie") #Need to add user for the folder
|
||||
|
||||
@@ -205,22 +204,26 @@ def hex2bytes(tales_instance, hex_value):
|
||||
with open("text_dump.txt", "w",encoding="utf-8") as f:
|
||||
f.write(txt)
|
||||
|
||||
|
||||
def getTalesInstance(game_name):
|
||||
|
||||
|
||||
if game_name == "TOR":
|
||||
talesInstance = ToolsTOR.ToolsTOR("TBL_All.json")
|
||||
elif game_name == "NDX":
|
||||
talesInstance = ToolsNDX.ToolsNDX("TBL_All.json")
|
||||
else:
|
||||
raise ValueError("Unkown game name")
|
||||
|
||||
return talesInstance
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
args = get_arguments()
|
||||
game_name = args.game
|
||||
tales_instance = getTalesInstance(game_name)
|
||||
org = repos_infos[game_name]['Org']
|
||||
repo_name = repos_infos[game_name]['Repo']
|
||||
org = repos_infos[game_name]["Org"]
|
||||
repo_name = repos_infos[game_name]["Repo"]
|
||||
|
||||
if args.action == "insert":
|
||||
|
||||
@@ -243,7 +246,7 @@ if __name__ == "__main__":
|
||||
#generate_xdelta_patch(repo_name, xdelta_name)
|
||||
|
||||
if args.action == "extract":
|
||||
|
||||
|
||||
if args.file_type == "Iso":
|
||||
tales_instance.extract_Iso(args.iso)
|
||||
tales_instance.extract_Main_Archive()
|
||||
@@ -253,7 +256,7 @@ if __name__ == "__main__":
|
||||
|
||||
if args.file_type == "Menu":
|
||||
tales_instance.extract_All_Menu()
|
||||
|
||||
|
||||
if args.file_type == "Story":
|
||||
tales_instance.extract_All_Story(args.replace)
|
||||
|
||||
@@ -263,4 +266,4 @@ if __name__ == "__main__":
|
||||
if args.action == "debug":
|
||||
|
||||
if args.file_type in ["Story", "Skits"]:
|
||||
tales_instance.debug_Story_Skits(args.file_type, args.file_name, args.text)
|
||||
tales_instance.debug_Story_Skits(args.file_type, args.file_name, args.text)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from ToolsTales import ToolsTales
|
||||
from .ToolsTales import ToolsTales
|
||||
import subprocess
|
||||
from dicttoxml import dicttoxml
|
||||
# from dicttoxml import dicttoxml
|
||||
import json
|
||||
import struct
|
||||
import shutil
|
||||
|
||||
@@ -1,19 +1,4 @@
|
||||
from ToolsTales import ToolsTales
|
||||
import subprocess
|
||||
from dicttoxml import dicttoxml
|
||||
import json
|
||||
import struct
|
||||
import shutil
|
||||
import os
|
||||
import re
|
||||
import pandas as pd
|
||||
import xml.etree.ElementTree as ET
|
||||
import lxml.etree as etree
|
||||
import comptolib
|
||||
from xml.dom import minidom
|
||||
from pathlib import Path
|
||||
import string
|
||||
import io
|
||||
from .ToolsTales import ToolsTales
|
||||
|
||||
class ToolsTODDC(ToolsTales):
|
||||
|
||||
|
||||
65
ToolsTOR.py
65
ToolsTOR.py
@@ -1,25 +1,25 @@
|
||||
from dataclasses import dataclass
|
||||
from itertools import tee
|
||||
from ToolsTales import ToolsTales
|
||||
import subprocess
|
||||
from dicttoxml import dicttoxml
|
||||
import io
|
||||
import json
|
||||
import struct
|
||||
import shutil
|
||||
import os
|
||||
import re
|
||||
import pandas as pd
|
||||
import xml.etree.ElementTree as ET
|
||||
import lxml.etree as etree
|
||||
import comptolib
|
||||
from xml.dom import minidom
|
||||
import shutil
|
||||
import struct
|
||||
from dataclasses import dataclass
|
||||
from itertools import tee
|
||||
from pathlib import Path
|
||||
import string
|
||||
import io
|
||||
|
||||
import lxml.etree as etree
|
||||
import pandas as pd
|
||||
from tqdm import tqdm
|
||||
from scpk import Scpk
|
||||
|
||||
import comptolib as comptolib
|
||||
import pak2 as pak2lib
|
||||
from theirsce import Theirsce
|
||||
from theirsce_instructions import AluOperation, InstructionType, ReferenceScope, TheirsceBaseInstruction, TheirsceReferenceInstruction, TheirsceStringInstruction
|
||||
from tqdm import tqdm
|
||||
from theirsce_instructions import (AluOperation, InstructionType,
|
||||
TheirsceBaseInstruction)
|
||||
from .ToolsTales import ToolsTales
|
||||
|
||||
|
||||
@dataclass
|
||||
class LineEntry:
|
||||
@@ -44,15 +44,15 @@ class ToolsTOR(ToolsTales):
|
||||
|
||||
|
||||
#Path to used
|
||||
dat_bin_original = '../Data/Tales-Of-Rebirth/Disc/Original/DAT.BIN'
|
||||
dat_bin_new = '../Data/Tales-Of-Rebirth/Disc/New/DAT.BIN'
|
||||
elf_original = '../Data/Tales-Of-Rebirth/Disc/Original/SLPS_254.50'
|
||||
elf_new = '../Data/Tales-Of-Rebirth/Disc/New/SLPS_254.50'
|
||||
story_XML_new = '../Tales-Of-Rebirth/Data/TOR/Story/' #Story XML files will be extracted here
|
||||
story_XML_patch = '../Data/Tales-Of-Rebirth/Story/' #Story XML files will be extracted here
|
||||
skit_XML_patch = '../Data/Tales-Of-Rebirth/Skits/' #Skits XML files will be extracted here
|
||||
skit_XML_new = '../Tales-Of-Rebirth/Data/TOR/Skits/'
|
||||
dat_archive_extract = '../Data/Tales-Of-Rebirth/DAT/'
|
||||
dat_bin_original = '../Data/Tales-Of-Rebirth/Disc/Original/DAT.BIN'
|
||||
dat_bin_new = '../Data/Tales-Of-Rebirth/Disc/New/DAT.BIN'
|
||||
elf_original = '../Data/Tales-Of-Rebirth/Disc/Original/SLPS_254.50'
|
||||
elf_new = '../Data/Tales-Of-Rebirth/Disc/New/SLPS_254.50'
|
||||
story_XML_new = '../Tales-Of-Rebirth/Data/TOR/Story/' #Story XML files will be extracted here
|
||||
story_XML_patch = '../Data/Tales-Of-Rebirth/Story/' #Story XML files will be extracted here
|
||||
skit_XML_patch = '../Data/Tales-Of-Rebirth/Skits/' #Skits XML files will be extracted here
|
||||
skit_XML_new = '../Tales-Of-Rebirth/Data/TOR/Skits/'
|
||||
dat_archive_extract = '../Data/Tales-Of-Rebirth/DAT/'
|
||||
|
||||
def __init__(self, tbl):
|
||||
|
||||
@@ -67,8 +67,7 @@ class ToolsTOR(ToolsTales):
|
||||
for k, v in self.jsonTblTags.items():
|
||||
self.ijsonTblTags[k] = {v2: k2 for k2, v2 in v.items()}
|
||||
self.id = 1
|
||||
|
||||
#byteCode
|
||||
# byteCode
|
||||
self.story_byte_code = b"\xF8"
|
||||
self.string_opcode = InstructionType.STRING
|
||||
self.list_status_insertion = ['Done', 'Proofreading', 'Editing']
|
||||
@@ -81,8 +80,8 @@ class ToolsTOR(ToolsTales):
|
||||
return new.join(li)
|
||||
|
||||
def add_line_break(self, text):
|
||||
temp = "";
|
||||
currentLineSize = 0;
|
||||
temp = ""
|
||||
currentLineSize = 0
|
||||
|
||||
text_size = len(text)
|
||||
max_size = 32
|
||||
@@ -619,8 +618,6 @@ class ToolsTOR(ToolsTales):
|
||||
|
||||
#Open the original SCPK
|
||||
with open( self.dat_archive_extract + "SCPK/" + scpk_file_name, 'r+b') as scpk:
|
||||
|
||||
|
||||
#Get nb_files and files_size
|
||||
scpk.read(4)
|
||||
scpk.read(4)
|
||||
@@ -641,10 +638,6 @@ class ToolsTOR(ToolsTales):
|
||||
for pointer_offset, fsize in file_size_dict.items():
|
||||
|
||||
data_compressed = scpk.read(fsize)
|
||||
|
||||
|
||||
|
||||
|
||||
if self.is_compressed(data_compressed):
|
||||
c_type = struct.unpack("<b", data_compressed[:1])[0]
|
||||
#print("File {} size: {} ctype: {}".format(i, fsize,c_type))
|
||||
@@ -669,8 +662,6 @@ class ToolsTOR(ToolsTales):
|
||||
|
||||
else:
|
||||
data_compressed = comptolib.compress_data(data_uncompressed, version=c_type)
|
||||
|
||||
|
||||
|
||||
#Updating the header of the SCPK file to adjust the size
|
||||
new_size = len(data_compressed)
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
import subprocess
|
||||
from dicttoxml import dicttoxml
|
||||
import json
|
||||
import struct
|
||||
import shutil
|
||||
import os
|
||||
import re
|
||||
import fps4
|
||||
import pandas as pd
|
||||
import xml.etree.ElementTree as ET
|
||||
import lxml.etree as etree
|
||||
from xml.dom import minidom
|
||||
import re
|
||||
import collections
|
||||
import comptolib
|
||||
import lxml.etree as ET
|
||||
import shutil
|
||||
import string
|
||||
import pygsheets
|
||||
import struct
|
||||
import subprocess
|
||||
from typing import Union
|
||||
import xml.etree.ElementTree as ET
|
||||
from pathlib import Path
|
||||
|
||||
import lxml.etree as etree
|
||||
import lxml.etree as ET
|
||||
import pandas as pd
|
||||
import pycdlib
|
||||
import collections
|
||||
import pygsheets
|
||||
from googleapiclient.errors import HttpError
|
||||
from tqdm import tqdm
|
||||
|
||||
import fps4 as fps4
|
||||
|
||||
|
||||
class ToolsTales:
|
||||
|
||||
@@ -1167,14 +1167,10 @@ class ToolsTales:
|
||||
iso.get_file_from_iso(os.path.join(extract_to, relname), **{pathname: ident_to_here})
|
||||
|
||||
iso.close()
|
||||
|
||||
|
||||
if self.repo_name == "Narikiri-Dungeon-X":
|
||||
|
||||
for element in os.listdir(extract_to):
|
||||
|
||||
if os.path.isdir(os.path.join(extract_to, element)):
|
||||
os.rename(os.path.join(extract_to, element), os.path.join(extract_to, "PSP_GAME"))
|
||||
else:
|
||||
os.rename(os.path.join(extract_to, element), os.path.join(extract_to, "UMD_DATA.BIN"))
|
||||
|
||||
|
||||
os.rename(os.path.join(extract_to, element), os.path.join(extract_to, "UMD_DATA.BIN"))
|
||||
10
theirsce.py
10
theirsce.py
@@ -1,10 +1,8 @@
|
||||
from itertools import tee, zip_longest
|
||||
from typing import Generator
|
||||
from FileIO import FileIO
|
||||
from dataclasses import dataclass, field
|
||||
from enum import Enum
|
||||
from theirsce_instructions import *
|
||||
from theirsce_funcs import *
|
||||
|
||||
from .FileIO import FileIO
|
||||
from .theirsce_funcs import *
|
||||
from .theirsce_instructions import *
|
||||
|
||||
# I followed other project when making this class
|
||||
# not sure how if it's the best approach
|
||||
|
||||
Reference in New Issue
Block a user