Renamed 'evaluations' to 'apis'

This commit is contained in:
faildev_mode 2023-05-30 18:27:20 +02:00
parent 337077602a
commit 42fb70b282
No known key found for this signature in database
GPG Key ID: 70845C70C0F5E205
2 changed files with 5 additions and 6 deletions

View File

@ -12,7 +12,7 @@ import frontmatter # from package python-frontmatter
import datetime
import re
from functools import partial
import evaluations # from itself
import apis # from itself
import traceback
def link_this(src: str, dest: str):
@ -93,14 +93,13 @@ def evaluate_content(match: re.Match, frontmatter_data: dict, path: str) -> str:
global config
match = match.group(1)
print(' '+match)
# prepare globals
global_ns = {
'__builtins__': {}
}
extension = vars(evaluations.Content)
extension = vars(apis.Content)
for i in extension.keys():
if i.startswith('_'): continue
global_ns[i] = extension[i]
@ -108,8 +107,8 @@ def evaluate_content(match: re.Match, frontmatter_data: dict, path: str) -> str:
global_ns.update(config['variables'])
global_ns['path'] = path
global_ns.update(frontmatter_data)
# this trick let the functions in evaluations.py access our environment
evaluations.environment = global_ns
# this trick let the functions in apis.py access our environment
apis.environment = global_ns
# now let's execute the command!
# unfortunately we can't use 'return' in expressions
# instead the last line will be evaluated and returned, the rest executed
@ -137,7 +136,7 @@ if __name__ == '__main__':
# load config
config = configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation())
config.read('config.ini')
evaluations.config = config # pass the config to evaluations module, so functions can read it
apis.config = config # pass the config to apis module, so functions can read it
# scan source files
content_files = scan_dir('content')