mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-01 17:39:39 +02:00
git-subtree-dir: ai-context/trustgraph-templates git-subtree-split: 42a5fd1b678f32be378062e30451e2052ccb95dd
23 lines
548 B
Python
Executable file
23 lines
548 B
Python
Executable file
|
|
import _gojsonnet as j
|
|
import json
|
|
import os
|
|
import pathlib
|
|
import logging
|
|
|
|
logger = logging.getLogger("generator")
|
|
logger.setLevel(logging.INFO)
|
|
|
|
class Generator:
|
|
|
|
def __init__(self, fetch):
|
|
self.fetch = fetch
|
|
|
|
def process(self, config):
|
|
res = j.evaluate_snippet("config", config, import_callback=self.fetch)
|
|
return json.loads(res)
|
|
|
|
def process_file(self, path):
|
|
content = path.read_text()
|
|
res = j.evaluate_snippet(str(path), content, import_callback=self.fetch)
|
|
return json.loads(res)
|