You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The converter by BaconWizard17 can convert NBA2kStuff's xml format to JSON which Xmlb can compile to raven formats (xmlb, etc).
NBA2kStuff's xmlb-compile has its own error logging, but the one from Raven-Formats' Xmlb is better in my opinion. I've been using the converter for all of NBA2kStuff's formats.
The format can exist with an .xml extension (suggested by XMLBCUI), so the detection by extension doesn't work with that added. I added a format detection in my batch for Raven-Formats (QuickBatch), which works like this: JSON begins with {, XML begins with <. I've been using it for a while and it has always worked. The batch does not test for NBA2kStuff's format (which usually begins with XMLB, but I am not certain that this is a rule) so all other formats are assumed to be his format. This is my recommendation. When we check for that first character, we have to exclude bit order marks from the search. I don't know how the read_string(xmlb_file, offset: int) command handles BOM, but I'm sure that this part is a lot easier in Python than CMD.
As for the conversion, I've been using this method to convert for many files and it works: Compile to xmlb, decompile back to desired format. Using current Xmlb creates a file and reads it again, which slows down the process in comparison to read and write from stream. I think that conversion should happen by extension, as JSON and XML formats both make the most sense when using their native extensions. And the conversion would probably need a new argument: -c, --convert. Without the argument, it would compile to xmlb, using the specified extension (e.g. test.xml in xmlb format).
On line 236, instead of going to convert, go to...
New function with format detection { and <. Reads file, passes 3 arguments: file as stream, format, output path. To convert or compile (decide with new argument args.convert). Convert also needs the argument has_indent (pass it through).
Modify compile function from extension to new argument ("xml", "json") on lines 202 and 204. Instead of the file extension [] is not supported error (214), use new function xml2json? (Converter by BaconWizard17), then handle JSON (new function?).
Modify decompile function to call new function (root_element2file).
New function (root_element2file? > arguments element: ET.Element?, output_path: Path, has_indent: bool) and move all parts of the decompile function except reading the file. New convert function needs this as well.
New convert function. I don't understand the ElementTree part, I assume root_element is an ET? This might require new or modified functions.
Decides input with received argument.
XML 2 ET: ET.fromstring(xml_as_string)
JSON 2 ET: data = json.load(json_as_string, object_pairs_hook=parse_json_object_pairs) (I think, not sure about the difference between load and loads) then, from_json_element(data[0]) (possibly make function, to also handle the root amount, see below)
NBA2kStuff's format 2 JSON: Use new Converter by BaconWizard17 (then use JSON 2 ET - a new function would really be better)
Pass the result (arguments ET.Element?, output path, has_indent) to (root_element2file)
The converter by BaconWizard17 can convert NBA2kStuff's xml format to JSON which Xmlb can compile to raven formats (xmlb, etc).
NBA2kStuff's xmlb-compile has its own error logging, but the one from Raven-Formats' Xmlb is better in my opinion. I've been using the converter for all of NBA2kStuff's formats.
The format can exist with an .xml extension (suggested by XMLBCUI), so the detection by extension doesn't work with that added. I added a format detection in my batch for Raven-Formats (QuickBatch), which works like this: JSON begins with
{
, XML begins with<
. I've been using it for a while and it has always worked. The batch does not test for NBA2kStuff's format (which usually begins withXMLB
, but I am not certain that this is a rule) so all other formats are assumed to be his format. This is my recommendation. When we check for that first character, we have to exclude bit order marks from the search. I don't know how theread_string(xmlb_file, offset: int)
command handles BOM, but I'm sure that this part is a lot easier in Python than CMD.As for the conversion, I've been using this method to convert for many files and it works: Compile to xmlb, decompile back to desired format. Using current Xmlb creates a file and reads it again, which slows down the process in comparison to read and write from stream. I think that conversion should happen by extension, as JSON and XML formats both make the most sense when using their native extensions. And the conversion would probably need a new argument:
-c
,--convert
. Without the argument, it would compile to xmlb, using the specified extension (e.g. test.xml in xmlb format).Required additions:
-c
--convert
arguments on line 220{
and<
. Reads file, passes 3 arguments: file as stream, format, output path. To convert or compile (decide with new argumentargs.convert
). Convert also needs the argument has_indent (pass it through).file extension [] is not supported
error (214), use new function xml2json? (Converter by BaconWizard17), then handle JSON (new function?).element: ET.Element
?, output_path: Path, has_indent: bool
) and move all parts of the decompile function except reading the file. New convert function needs this as well.root_element
is an ET? This might require new or modified functions.ET.fromstring(xml_as_string)
data = json.load(json_as_string, object_pairs_hook=parse_json_object_pairs)
(I think, not sure about the difference between load and loads) then,from_json_element(data[0])
(possibly make function, to also handle the root amount, see below)file_name: Path
tofile
The text was updated successfully, but these errors were encountered: