瀏覽代碼

Fix yaml env loading

master
Marien Fressinaud 5 年之前
父節點
當前提交
9a223fa105
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3
    3
      boop.py

+ 3
- 3
boop.py 查看文件

@@ -24,7 +24,7 @@ OUTPUT_DIR_NAME = "output"
# Configure YAML to accept environment variables in metadata files
# Based on https://stackoverflow.com/a/27232341 solution
pattern = re.compile(r"^ENV\[\'(.*)\'\]$")
yaml.add_implicit_resolver("!pathex", pattern)
yaml.add_implicit_resolver("!pathex", pattern, Loader=yaml.SafeLoader)


def pathex_constructor(loader, node):
@@ -33,7 +33,7 @@ def pathex_constructor(loader, node):
return os.getenv(env_var)


yaml.add_constructor("!pathex", pathex_constructor)
yaml.add_constructor("!pathex", pathex_constructor, yaml.SafeLoader)


def list_galleries_in(path):
@@ -43,7 +43,7 @@ def list_galleries_in(path):
metadata_path = os.path.join(gallery_dir.path, "metadata.yml")
if os.path.exists(metadata_path):
with open(metadata_path, "r") as metadata_file:
metadata = yaml.load(metadata_file)
metadata = yaml.safe_load(metadata_file)

private = False
url = f"{gallery_dir.name}.html"

Loading…
取消
儲存