mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-31 20:00:09 +00:00
[xml] Improvements.
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
# This file will be downloaded by download_assets.py
|
||||
unicode.xml
|
||||
@@ -50,10 +50,7 @@ def try_download_file(url, out_file):
|
||||
print("Could not download", url)
|
||||
return 1
|
||||
|
||||
def try_download_and_unpack_zip(suite):
|
||||
url = ASSETS_BASE_URL.format(suite, "{}.zip".format(suite))
|
||||
out_file = DOWNLOAD_BASE_PATH.format(suite) + "/{}.zip".format(suite)
|
||||
|
||||
def try_download_and_unpack_zip(url, out_file, extract_path):
|
||||
print("\tDownloading {} to {}.".format(url, out_file))
|
||||
|
||||
if try_download_file(url, out_file) is not None:
|
||||
@@ -65,7 +62,6 @@ def try_download_and_unpack_zip(suite):
|
||||
with zipfile.ZipFile(out_file) as z:
|
||||
for file in z.filelist:
|
||||
filename = file.filename
|
||||
extract_path = DOWNLOAD_BASE_PATH.format(suite)
|
||||
|
||||
print("\t\tExtracting: {}".format(filename))
|
||||
z.extract(file, extract_path)
|
||||
@@ -73,25 +69,56 @@ def try_download_and_unpack_zip(suite):
|
||||
print("Could not extract ZIP file")
|
||||
return 2
|
||||
|
||||
def download_png_assets():
|
||||
suite = "PNG"
|
||||
url = ASSETS_BASE_URL.format(suite, "{}.zip".format(suite))
|
||||
out_file = DOWNLOAD_BASE_PATH.format(suite) + "/{}.zip".format(suite)
|
||||
extract_path = DOWNLOAD_BASE_PATH.format(suite)
|
||||
|
||||
def main():
|
||||
print("Downloading PNG assets")
|
||||
|
||||
# Make PNG assets path
|
||||
try:
|
||||
path = DOWNLOAD_BASE_PATH.format("PNG")
|
||||
path = DOWNLOAD_BASE_PATH.format(suite)
|
||||
os.makedirs(path)
|
||||
except FileExistsError:
|
||||
pass
|
||||
|
||||
# Try downloading and unpacking the PNG assets
|
||||
r = try_download_and_unpack_zip("PNG")
|
||||
r = try_download_and_unpack_zip(url, out_file, extract_path)
|
||||
if r is not None:
|
||||
return r
|
||||
|
||||
# We could fall back on downloading the PNG files individually, but it's slow
|
||||
|
||||
print("Done downloading PNG assets")
|
||||
|
||||
def download_unicode_assets():
|
||||
suite = "XML"
|
||||
url = "https://www.w3.org/2003/entities/2007xml/unicode.xml.zip"
|
||||
out_file = DOWNLOAD_BASE_PATH.format(suite) + "/{}.zip".format(suite)
|
||||
extract_path = DOWNLOAD_BASE_PATH.format(suite)
|
||||
|
||||
print("Downloading {}.".format(url))
|
||||
|
||||
# Make XML assets path
|
||||
try:
|
||||
path = DOWNLOAD_BASE_PATH.format(suite)
|
||||
os.makedirs(path)
|
||||
except FileExistsError:
|
||||
pass
|
||||
|
||||
# Try downloading and unpacking the assets
|
||||
r = try_download_and_unpack_zip(url, out_file, extract_path)
|
||||
if r is not None:
|
||||
return r
|
||||
|
||||
print("Done downloading Unicode/XML assets")
|
||||
|
||||
def main():
|
||||
download_png_assets()
|
||||
download_unicode_assets()
|
||||
|
||||
return 0
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -35,7 +35,7 @@ TESTS :: []TEST{
|
||||
First we test that certain files parse without error.
|
||||
*/
|
||||
{
|
||||
filename = "assets/xml/utf8.xml",
|
||||
filename = "assets/XML/utf8.xml",
|
||||
options = OPTIONS,
|
||||
expected = {
|
||||
error = .None,
|
||||
@@ -45,7 +45,7 @@ TESTS :: []TEST{
|
||||
},
|
||||
},
|
||||
{
|
||||
filename = "assets/xml/nl_NL-qt-ts.ts",
|
||||
filename = "assets/XML/nl_NL-qt-ts.ts",
|
||||
options = OPTIONS,
|
||||
expected = {
|
||||
error = .None,
|
||||
@@ -55,7 +55,7 @@ TESTS :: []TEST{
|
||||
},
|
||||
},
|
||||
{
|
||||
filename = "assets/xml/nl_NL-xliff-1.0.xliff",
|
||||
filename = "assets/XML/nl_NL-xliff-1.0.xliff",
|
||||
options = OPTIONS,
|
||||
expected = {
|
||||
error = .None,
|
||||
@@ -65,7 +65,7 @@ TESTS :: []TEST{
|
||||
},
|
||||
},
|
||||
{
|
||||
filename = "assets/xml/nl_NL-xliff-2.0.xliff",
|
||||
filename = "assets/XML/nl_NL-xliff-2.0.xliff",
|
||||
options = OPTIONS,
|
||||
expected = {
|
||||
error = .None,
|
||||
@@ -79,7 +79,7 @@ TESTS :: []TEST{
|
||||
Then we test that certain errors are returned as expected.
|
||||
*/
|
||||
{
|
||||
filename = "assets/xml/utf8.xml",
|
||||
filename = "assets/XML/utf8.xml",
|
||||
options = {
|
||||
flags = {
|
||||
.Ignore_Unsupported, .Intern_Comments,
|
||||
|
||||
Reference in New Issue
Block a user