Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion install_cornucopia_deps.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ lxml == 5.4.0 --hash=sha256:d2ed1b3cb9ff1c10e6e8b00941bb2e5bb568b307bfc6b17dffbb
docx2pdf == 0.1.8 --hash=sha256:6d2c20f9ad36eec75f4da017dc7a97622946954a6124ca0b11772875fa86fbed
click == 8.3.2 --hash=sha256:14162b8b3b3550a7d479eafa77dfd3c38d9dc8951f6f69c78913a8f9a7540fd5 --hash=sha256:1924d2c27c5653561cd2cae4548d1406039cb79b858b747cfea24924bbc1616d
mypy-extensions == 1.1.0 --hash=sha256:1be4cccdb0f2482337c4743e60421de3a356cd97508abadd57d47403e94f5505 --hash=sha256:52e68efc3284861e772bbcd66823fde5ae21fd2fdb51c62a211403730b916558
pathspec == 0.12.1 --hash=sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08
pathspec == 1.0.4 --hash=sha256:fb6ae2fd4e7c921a165808a552060e722767cfa526f99ca5156ed2ce45a5c723
tomli == 2.4.1 --hash=sha256:01f520d4f53ef97964a240a035ec2a869fe1a37dde002b57ebc4417a27ccd853 --hash=sha256:0d85819802132122da43cb86656f8d1f8c6587d54ae7dcaf30e90533028b49fe --hash=sha256:136443dbd7e1dee43c68ac2694fde36b2849865fa258d39bf822c10e8068eac5 --hash=sha256:1d8591993e228b0c930c4bb0db464bdad97b3289fb981255d6c9a41aedc84b2d --hash=sha256:2190f2e9dd7508d2a90ded5ed369255980a1bcdd58e52f7fe24b8162bf9fedbd --hash=sha256:2c1c351919aca02858f740c6d33adea0c5deea37f9ecca1cc1ef9e884a619d26 --hash=sha256:36d2bd2ad5fb9eaddba5226aa02c8ec3fa4f192631e347b3ed28186d43be6b54 --hash=sha256:3d48a93ee1c9b79c04bb38772ee1b64dcf18ff43085896ea460ca8dec96f35f6 --hash=sha256:47149d5bd38761ac8be13a84864bf0b7b70bc051806bc3669ab1cbc56216b23c --hash=sha256:4ab97e64ccda8756376892c53a72bd1f964e519c77236368527f758fbc36a53a --hash=sha256:4b605484e43cdc43f0954ddae319fb75f04cc10dd80d830540060ee7cd0243cd --hash=sha256:504aa796fe0569bb43171066009ead363de03675276d2d121ac1a4572397870f --hash=sha256:51529d40e3ca50046d7606fa99ce3956a617f9b36380da3b7f0dd3dd28e68cb5 --hash=sha256:52c8ef851d9a240f11a88c003eacb03c31fc1c9c4ec64a99a0f922b93874fda9 --hash=sha256:559db847dc486944896521f68d8190be1c9e719fced785720d2216fe7022b662 --hash=sha256:5a881ab208c0baf688221f8cecc5401bd291d67e38a1ac884d6736cbcd8247e9 --hash=sha256:5cb41aa38891e073ee49d55fbc7839cfdb2bc0e600add13874d048c94aadddd1 --hash=sha256:5e262d41726bc187e69af7825504c933b6794dc3fbd5945e41a79bb14c31f585 --hash=sha256:5ee18d9ebdb417e384b58fe414e8d6af9f4e7a0ae761519fb50f721de398dd4e --hash=sha256:7008df2e7655c495dd12d2a4ad038ff878d4ca4b81fccaf82b714e07eae4402c --hash=sha256:734e20b57ba95624ecf1841e72b53f6e186355e216e5412de414e3c51e5e3c41 --hash=sha256:7c7e1a961a0b2f2472c1ac5b69affa0ae1132c39adcb67aba98568702b9cc23f --hash=sha256:7f86fd587c4ed9dd76f318225e7d9b29cfc5a9d43de44e5754db8d1128487085 --hash=sha256:7f94b27a62cfad8496c8d2513e1a222dd446f095fca8987fceef261225538a15 --hash=sha256:88dceee75c2c63af144e456745e10101eb67361050196b0b6af5d717254dddf7 --hash=sha256:8a650c2dbafa08d42e51ba0b62740dae4ecb9338eefa093aa5c78ceb546fcd5c --hash=sha256:8d65a2fbf9d2f8352685bc1364177ee3923d6baf5e7f43ea4959d7d8bc326a36 --hash=sha256:96481a5786729fd470164b47cdb3e0e58062a496f455ee41b4403be77cb5a076 --hash=sha256:a120733b01c45e9a0c34aeef92bf0cf1d56cfe81ed9d47d562f9ed591a9828ac --hash=sha256:b1d22e6e9387bf4739fbe23bfa80e93f6b0373a7f1b96c6227c32bef95a4d7a8 --hash=sha256:b8c198f8c1805dc42708689ed6864951fd2494f924149d3e4bce7710f8eb5232 --hash=sha256:c2541745709bad0264b7d4705ad453b76ccd191e64aa6f0fc66b69a293a45ece --hash=sha256:c742f741d58a28940ce01d58f0ab2ea3ced8b12402f162f4d534dfe18ba1cd6a --hash=sha256:c7f2c7f2b9ca6bdeef8f0fa897f8e05085923eb091721675170254cbc5b02897 --hash=sha256:d312ef37c91508b0ab2cee7da26ec0b3ed2f03ce12bd87a588d771ae15dcf82d --hash=sha256:d4d8fe59808a54658fcc0160ecfb1b30f9089906c50b23bcb4c69eddc19ec2b4 --hash=sha256:da25dc3563bff5965356133435b757a795a17b17d01dbc0f42fb32447ddfd917 --hash=sha256:eab21f45c7f66c13f2a9e0e1535309cee140182a9cdae1e041d02e47291e8396 --hash=sha256:eb0dc4e38e6a1fd579e5d50369aa2e10acfc9cace504579b2faabb478e76941a --hash=sha256:ec9bfaf3ad2df51ace80688143a6a4ebc09a248f6ff781a9945e51937008fcbc --hash=sha256:ede3e6487c5ef5d28634ba3f31f989030ad6af71edfb0055cbbd14189ff240ba --hash=sha256:f3c6818a1a86dd6dca7ddcaaf76947d5ba31aecc28cb1b67009a5877c9a64f3f --hash=sha256:f758f1b9299d059cc3f6546ae2af89670cb1c4d48ea29c3cacc4fe7de3058257 --hash=sha256:f8f0fc26ec2cc2b965b7a3b87cd19c5c6b8c5e5f436b984e85f486d652285c30 --hash=sha256:fd0409a3653af6c147209d267a0e4243f0ae46b011aa978b1080359fddc9b6cf --hash=sha256:ff18e6a727ee0ab0388507b89d1bc6a22b138d1e2fa56d1ad494586d61d2eae9 --hash=sha256:ff2983983d34813c1aeb0fa89091e76c3a22889ee83ab27c5eeb45100560c049
mccabe == 0.7.0 --hash=sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e
pycodestyle == 2.13.0 --hash=sha256:35863c5974a271c7a726ed228a14a4f6daf49df369d8c50cd9a6f58a5e143ba9 --hash=sha256:c8415bf09abe81d9c7f872502a6eee881fbe85d8763dd5b9924bb0a01d67efae
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
23 changes: 17 additions & 6 deletions scripts/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def create_edition_from_template(
logging.error("No metadata found. Cannot proceed.")
return

template_doc: str = get_template_for_edition(layout, template, edition)
template_doc: str = get_template_for_edition(layout, template, edition, language)
if template_doc == "None":
return
file_name, file_extension = os.path.splitext(template_doc)
Expand Down Expand Up @@ -952,7 +952,9 @@ def get_suit_tags_and_key(key: str, edition: str) -> Tuple[List[str], str]:
return suit_tags, suit_key


def get_template_for_edition(layout: str = "guide", template: str = "bridge", edition: str = "webapp") -> str:
def get_template_for_edition(
layout: str = "guide", template: str = "bridge", edition: str = "webapp", language: str = "en"
) -> str:
"""Get template document for the specified edition."""
template_doc: str
args_input_file: str = convert_vars.args.inputfile
Expand Down Expand Up @@ -981,16 +983,25 @@ def get_template_for_edition(layout: str = "guide", template: str = "bridge", ed
template_doc = args_input_file
logging.debug(f" --- Template_doc NOT found. Input File = {args_input_file}")
else:
# No input file specified - using defaults
template_doc = os.path.normpath(
# No input file specified - try language-specific template first, then fall back to generic
base_template = (
convert_vars.BASE_PATH
+ os.sep
+ convert_vars.DEFAULT_TEMPLATE_FILENAME.replace("edition", edition)
.replace("layout", layout)
.replace("document_template", template)
+ "."
+ sfile_ext
)
# Build language-specific path (e.g. ..._bridge_en.odt)
lang_template_doc = os.path.normpath(base_template.replace("_lang", "_" + language) + "." + sfile_ext)
# Build generic fallback path (e.g. ..._bridge_lang.odt)
generic_template_doc = os.path.normpath(base_template + "." + sfile_ext)

if os.path.isfile(lang_template_doc):
template_doc = lang_template_doc
logging.info(f" --- Using language-specific template: {lang_template_doc}")
else:
template_doc = generic_template_doc
logging.info(f" --- Using generic template (no language-specific found): {generic_template_doc}")

template_doc = template_doc.replace("\\ ", " ")
template_doc = str(Path(sanitize_filepath(template_doc)))
Expand Down
5 changes: 3 additions & 2 deletions tests/scripts/convert_utest.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,14 +325,15 @@ def test_get_template_for_edition_default_docx(self) -> None:
layout = "guide"
template = "bridge"
edition = "webapp"
language = "en"

want_template_doc = os.path.normpath(
os.path.join(
c.convert_vars.BASE_PATH, "resources", "templates", "owasp_cornucopia_webapp_ver_guide_bridge_lang.odt"
c.convert_vars.BASE_PATH, "resources", "templates", "owasp_cornucopia_webapp_ver_guide_bridge_en.odt"
)
)

got_template_doc = c.get_template_for_edition(layout, template, edition)
got_template_doc = c.get_template_for_edition(layout, template, edition, language)
self.assertEqual(want_template_doc, got_template_doc)

def test_get_template_for_edition_default_idml(self) -> None:
Expand Down
Loading