Updated checkDatatables.py, added language switch

This commit is contained in:
Farewell_ 2023-11-20 16:33:41 +01:00
parent 17695a7b9a
commit beb8feede8
2 changed files with 46 additions and 67 deletions

View File

@ -70,7 +70,8 @@ py sortAlphabetically.py --restore
## checkDatatables.py ## checkDatatables.py
This script generates a comprehensive list of various informations regarding your database files. It is meant to be used for basic checks such as: This script generates a comprehensive list of various informations regarding your database files for a given language.
It is meant to be used for basic checks such as:
* Listing the amount of songs in your tables * Listing the amount of songs in your tables
* Listing all vacant entries bellow 1599 to facilitate adding songs in * Listing all vacant entries bellow 1599 to facilitate adding songs in
@ -80,8 +81,13 @@ This script generates a comprehensive list of various informations regarding you
* Checking for id and uniqueId mismatches in various files * Checking for id and uniqueId mismatches in various files
* Checking for missing sound and fumen files * Checking for missing sound and fumen files
Possible languages are : japaneseText, englishUsText, chineseTText, chineseSText and koreanText.
To run this one you simply need to call it like so: To run this one you simply need to call it like so:
> py checkDatatables.py ```py
# Check datatables
py checkDatatables.py --language "englishUsText"
```
The output will be written in a file named `checks.json` The output will be written in a file named `checks.json`

View File

@ -1,8 +1,6 @@
from argparse import ArgumentParser
from enum import Enum from enum import Enum
import gzip
from encryption import decrypt_file
import json import json
import os
from helpers import ( from helpers import (
doesPathExist, doesPathExist,
@ -13,12 +11,29 @@ from helpers import (
loadFile, loadFile,
) )
# "japaneseText" if __name__ == "__main__":
# "englishUsText" parser = ArgumentParser()
# "chineseTText" parser.add_argument(
# "koreanText" "-l",
# "chineseSText" "--language",
language = "englishUsText" default="englishUsText",
help="This sets the language used for sorting the files. Possible values are : japaneseText, englishUsText, chineseTText, chineseSText and koreanText",
)
args = parser.parse_args()
language = args.language
if language not in [
"japaneseText",
"englishUsText",
"chineseTText",
"chineseSText",
"koreanText",
]:
print(
"Invalid language, Possible values are : japaneseText, englishUsText, chineseTText, chineseSText and koreanText"
)
exit(1)
isChn = isChn() isChn = isChn()
@ -32,10 +47,6 @@ attributes = loadFile(path="./Data/x64/datatable/music_attribute.bin")
words = loadFile(path="./Data/x64/datatable/wordlist.bin") words = loadFile(path="./Data/x64/datatable/wordlist.bin")
# endregion # endregion
# Forcing japanese language on 08.18 as this is what is usually used for omnimix.
if isCHN:
language = "japaneseText"
# region Classes And Methods # region Classes And Methods
class Genres(Enum): class Genres(Enum):
@ -56,42 +67,21 @@ class Genres(Enum):
return cls.Unknown return cls.Unknown
def findKeyInList(list: list, key: str, keyValue, value=None): class Song:
for object in list: id = ""
if object[key] == keyValue: uniqueId = -1
if value is not None: genreNo = -1
return object[value] name = ""
else: sub = ""
return object detail = ""
if value is not None: def __init__(self, id, uniqueId, genreNo, name, sub, detail):
return "" self.id = id
else: self.uniqueId = uniqueId
return None self.genreNo = genreNo
self.name = name
self.sub = sub
def findAllObjects(list: list, key: str, keyValue): self.detail = detail
templist = []
templist.append(list)
objects = []
for element in templist[0]:
if element[key] == keyValue:
objects.append(element)
return objects
def findDoubloninList(list: list, key: str, keyValue):
if len(findAllObjects(list=list, key=key, keyValue=keyValue)) > 1:
return True
return False
def doesPathExist(path: str):
if os.path.exists(path):
return True
return False
def initCheckFile(): def initCheckFile():
@ -169,23 +159,6 @@ def initCheckFile():
) )
class Song:
id = ""
uniqueId = -1
genreNo = -1
name = ""
sub = ""
detail = ""
def __init__(self, id, uniqueId, genreNo, name, sub, detail):
self.id = id
self.uniqueId = uniqueId
self.genreNo = genreNo
self.name = name
self.sub = sub
self.detail = detail
# endregion # endregion
# Loading all songs from musicinfo in an array # Loading all songs from musicinfo in an array