Renamed 'evaluations' to 'apis'
This commit is contained in:
parent
337077602a
commit
42fb70b282
|
@ -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')
|
||||
|
|
Reference in New Issue