mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-11 20:43:25 -08:00
[Oracle] Load card tags from a tag database during import
Add a TagDatabase loader that understands Scryfall's Oracle Tags bulk data and user-supplied tag files (tag objects, flat oracle-id or name maps, optional manifest, JSON or JSONL, gzip/xz/zip). The importer joins the slugs on identifiers.scryfallOracleId while the identifiers are still available, falls back to the card name, and unions them with any tags the source already provides. Split-card faces merge through the existing tag union path. This replaces oracle/scripts/inject_scryfall_tags.py, which patched AllPrintings.json before import. Loading during import keeps tags on by default for every source and lets users pair Oracle with any tag database.
This commit is contained in:
parent
0f45dfa12a
commit
77179f913e
9 changed files with 1145 additions and 217 deletions
|
|
@ -1,3 +1,35 @@
|
|||
# Optional compression libs, mirrored from oracle/CMakeLists.txt, so the tag database
|
||||
# loader can decompress whatever format the tag source serves, and the benchmark can
|
||||
# download and decompress whatever AllPrintings format the default URL selects.
|
||||
# add_definitions() is directory-scoped and order-independent, so HAS_ZLIB/HAS_LZMA
|
||||
# reach every test target below regardless of where they are declared.
|
||||
set(_ORACLE_COMPRESSION_SOURCES)
|
||||
set(_ORACLE_COMPRESSION_LIBRARIES)
|
||||
|
||||
find_package(ZLIB)
|
||||
if(ZLIB_FOUND)
|
||||
add_definitions("-DHAS_ZLIB")
|
||||
list(APPEND _ORACLE_COMPRESSION_SOURCES ../../oracle/src/zip/unzip.cpp ../../oracle/src/zip/zipglobal.cpp)
|
||||
cockatrice_disable_sanitizers_for(${_ORACLE_COMPRESSION_SOURCES})
|
||||
cockatrice_disable_coverage_for(${_ORACLE_COMPRESSION_SOURCES})
|
||||
list(APPEND _ORACLE_COMPRESSION_LIBRARIES ${ZLIB_LIBRARIES})
|
||||
include_directories(${ZLIB_INCLUDE_DIRS})
|
||||
else()
|
||||
message(STATUS "Oracle tests: zlib not found; gzip/zip tag databases and the zip download benchmark disabled")
|
||||
endif()
|
||||
|
||||
find_package(LibLZMA)
|
||||
if(LIBLZMA_FOUND)
|
||||
add_definitions("-DHAS_LZMA")
|
||||
list(APPEND _ORACLE_COMPRESSION_SOURCES ../../oracle/src/lzma/decompress.cpp)
|
||||
cockatrice_disable_sanitizers_for(../../oracle/src/lzma/decompress.cpp)
|
||||
cockatrice_disable_coverage_for(../../oracle/src/lzma/decompress.cpp)
|
||||
list(APPEND _ORACLE_COMPRESSION_LIBRARIES ${LIBLZMA_LIBRARIES})
|
||||
include_directories(${LIBLZMA_INCLUDE_DIRS})
|
||||
else()
|
||||
message(STATUS "Oracle tests: LibLZMA not found; xz tag databases and the xz download benchmark disabled")
|
||||
endif()
|
||||
|
||||
cockatrice_add_test(NAME parse_cipt_test SOURCES ../../oracle/src/parsehelpers.cpp parse_cipt_test.cpp)
|
||||
|
||||
# Oracle importer unit tests
|
||||
|
|
@ -9,42 +41,29 @@ cockatrice_add_test(
|
|||
../../oracle/src/oracleimporter.cpp
|
||||
../../oracle/src/parsehelpers.cpp
|
||||
../../oracle/src/raw_json_scanner.cpp
|
||||
../../oracle/src/tag_database.cpp
|
||||
oracle_importer_test.cpp
|
||||
${_ORACLE_COMPRESSION_SOURCES}
|
||||
LIBS
|
||||
libcockatrice_card
|
||||
libcockatrice_interfaces
|
||||
EXTRA_LIBS
|
||||
${_ORACLE_COMPRESSION_LIBRARIES}
|
||||
)
|
||||
|
||||
# Tag database format detection, parsing and parent expansion
|
||||
cockatrice_add_test(
|
||||
NAME
|
||||
tag_database_test
|
||||
SOURCES
|
||||
../../oracle/src/tag_database.cpp
|
||||
tag_database_test.cpp
|
||||
${_ORACLE_COMPRESSION_SOURCES}
|
||||
EXTRA_LIBS
|
||||
${_ORACLE_COMPRESSION_LIBRARIES}
|
||||
)
|
||||
|
||||
# Oracle importer benchmark tests (manual, not run in CI, incl. RAM benchmark)
|
||||
# Optional compression libs, mirrored from oracle/CMakeLists.txt, so the benchmark
|
||||
# can download and decompress whatever AllPrintings format the default URL selects.
|
||||
# add_definitions() is directory-scoped and order-independent, so HAS_ZLIB/HAS_LZMA also
|
||||
# reach the two unit tests above. That is harmless: those macros gate code only in
|
||||
# oracle/src/pages.cpp and oracle/src/pagetemplates.cpp, which no test target compiles.
|
||||
find_package(ZLIB)
|
||||
if(ZLIB_FOUND)
|
||||
add_definitions("-DHAS_ZLIB")
|
||||
set(_ORACLE_BENCH_EXTRA_SOURCES ../../oracle/src/zip/unzip.cpp ../../oracle/src/zip/zipglobal.cpp)
|
||||
cockatrice_disable_sanitizers_for(${_ORACLE_BENCH_EXTRA_SOURCES})
|
||||
cockatrice_disable_coverage_for(${_ORACLE_BENCH_EXTRA_SOURCES})
|
||||
set(_ORACLE_BENCH_EXTRA_LIBRARIES ${ZLIB_LIBRARIES})
|
||||
include_directories(${ZLIB_INCLUDE_DIRS})
|
||||
else()
|
||||
message(STATUS "Oracle tests: zlib not found; zip download benchmark disabled")
|
||||
endif()
|
||||
|
||||
find_package(LibLZMA)
|
||||
if(LIBLZMA_FOUND)
|
||||
add_definitions("-DHAS_LZMA")
|
||||
list(APPEND _ORACLE_BENCH_EXTRA_SOURCES ../../oracle/src/lzma/decompress.cpp)
|
||||
cockatrice_disable_sanitizers_for(../../oracle/src/lzma/decompress.cpp)
|
||||
cockatrice_disable_coverage_for(../../oracle/src/lzma/decompress.cpp)
|
||||
list(APPEND _ORACLE_BENCH_EXTRA_LIBRARIES ${LIBLZMA_LIBRARIES})
|
||||
include_directories(${LIBLZMA_INCLUDE_DIRS})
|
||||
else()
|
||||
message(STATUS "Oracle tests: LibLZMA not found; xz download benchmark disabled")
|
||||
endif()
|
||||
|
||||
cockatrice_add_manual_test(
|
||||
NAME
|
||||
oracle_importer_benchmark_test
|
||||
|
|
@ -53,12 +72,13 @@ cockatrice_add_manual_test(
|
|||
../../oracle/src/oracleimporter.cpp
|
||||
../../oracle/src/parsehelpers.cpp
|
||||
../../oracle/src/raw_json_scanner.cpp
|
||||
../../oracle/src/tag_database.cpp
|
||||
oracle_importer_benchmark_test.cpp
|
||||
${_ORACLE_BENCH_EXTRA_SOURCES}
|
||||
${_ORACLE_COMPRESSION_SOURCES}
|
||||
LIBS
|
||||
libcockatrice_card
|
||||
libcockatrice_interfaces
|
||||
EXTRA_LIBS
|
||||
${_ORACLE_BENCH_EXTRA_LIBRARIES}
|
||||
${_ORACLE_COMPRESSION_LIBRARIES}
|
||||
MANUAL
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue