Skip to content

Commit a21cb1d

Browse files
committed
Update build_for_portal for publishing books to portal
1 parent 7415c6c commit a21cb1d

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

build_for_portal.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import time
1616
import yaml
1717
import requests
18+
import tempfile
1819

1920
from aura import cli
2021

@@ -144,13 +145,28 @@ def find_build_config_file():
144145
"""
145146
Finds the build config file to use, as it might be _topic_map.yml or _build_cfg.yml
146147
"""
147-
config = os.path.abspath(os.path.join(CLONE_DIR, "_topic_map.yml"))
148+
149+
# updated 23rd Nov to support files in _topic_maps folder
150+
151+
# load everything from the _topic_maps folder
152+
file_list = os.listdir(os.path.join(CLONE_DIR, "_topic_maps"))
153+
154+
# create a temp file combining all values from that folder
155+
# don't delete it immediately, and give it a suffix of swp which makes it ignored by git
156+
with tempfile.NamedTemporaryFile(dir=CLONE_DIR, delete=False, suffix=".swp") as tmp:
157+
for f in file_list:
158+
with open(os.path.join(CLONE_DIR, "_topic_maps", f), "rb") as infile:
159+
tmp.write(infile.read())
160+
161+
config = os.path.abspath(tmp.name)
162+
log.info(config)
163+
164+
# backup look for a single _topic_map in the cloned directory
148165
if not os.path.isfile(config):
149-
config = os.path.abspath(os.path.join(CLONE_DIR, "_build_cfg.yml"))
166+
config = os.path.abspath(os.path.join(CLONE_DIR, "_topic_map.yml"))
150167

151168
return config
152169

153-
154170
def parse_build_config(config):
155171
"""
156172
Parses the build config and returns a tree based structure for the config.

0 commit comments

Comments
 (0)