コード例 #1
0
def add_globals(table):
    GLOBAL_VARS = read_properties(sembind.get_var('hints'))
    template_name = sembind.get_var('namet').split('/')[-1].replace(
        '.sem.py', '')
    for x in GLOBAL_VARS:
        table[x] = GLOBAL_VARS[x]
        lst = x.split('.')
        # override for sub-commands
        if len(lst) > 1 and lst[1] == template_name:
            table[lst[0]] = GLOBAL_VARS[x]
コード例 #2
0
def template_dir():
    return sembind.get_var('template_dir')
コード例 #3
0
#! /usr/bin/env python
# encoding: utf-8
# Thomas Nagy, 2007-2018 GPLV3

from html.parser import HTMLParser
import os, sys, sembind, re

protectXML = sembind.protectXML
sys.path = [sembind.get_var('template_dir')] + sys.path

if not hasattr(sys, "argv"): sys.argv = ['semantik']
#sys.stderr.write(str(sys.argv))


def subst_vars(doc, map):
    ugh = '-<[{($)}]>-'
    tmp = doc.replace('%', ugh)
    m4_re = re.compile('@(\w+)@', re.M)
    tmp = m4_re.sub(r'%(\1)s', tmp)
    tmp = tmp % map
    tmp = tmp.replace(ugh, '%')
    return tmp


def visualize(type, doc):
    var = 'command_' + type
    if var in settings:
        os.popen(settings[var] % doc).read()
    else:
        sembind.set_var('preview', doc)