Beispiel #1
0
def onCreate(tag, keys):
    """auto_colorize onCreate handler."""
    # pylint: disable=no-member
    # g.visit_tree_item does exist.
    try:
        c = keys.get('c')
        init_dict(c)
        g.visit_tree_item.add(colorize)
    except Exception as e:
        g.es_trace("Could not load commander." + str(e))
def onCreate (tag, keys):
    '''auto_colorize onCreate handler.'''
    # pylint: disable=no-member
    # g.visit_tree_item does exist.
    try:
        c = keys.get('c')
        init_dict(c)
        g.visit_tree_item.add(colorize)
    except Exception as e:
        g.es_trace("Could not load commander." + str(e))
Beispiel #3
0
def init_dict(c):
    """ (Re)Initialize the formats dictionary """
    cs = str(c)
    try:
        fbody = g.findNodeAnywhere(c, "Headline Formats").b
    except Exception as e:
        g.es_trace("This outline has no Headline Formats node\n" + str(e))
        return
    try:
        # There is something wrong. Both pylint and mypy complain.
        # pylint: disable=no-value-for-parameter
        formats = yaml.load(fbody)  # type:ignore
    except Exception as e:
        g.es_trace("Could not parse Headline Format yaml file\n" + str(e))
        return
    try:
        formats = formats["Headline Formats"]
    except Exception as e:
        g.es_trace("Yaml file does not have proper heading.\n" + str(e))
        return
    #preprocess multi headline styles
    g.app.permanentScriptDict[cs + 'formats'] = {}
    try:
        for k, f in formats.items():
            if "`" in k:
                _ = k.split("`")
                for _1 in _:
                    g.app.permanentScriptDict[cs + 'formats'][_1.strip()] = f
            else:
                g.app.permanentScriptDict[cs + 'formats'][k] = f
    except Exception as e:
        g.es_error(e)
def init_dict(c):
    """ (Re)Initialize the formats dictionary """
    cs = str(c)
    try:
        fbody = g.findNodeAnywhere(c, "Headline Formats").b
    except Exception as e:
        g.es_trace("This outline has no Headline Formats node\n" + str(e))
        return
    try:
        formats = yaml.load(fbody)
    except Exception as e:
        g.es_trace("Could not parse Headline Format yaml file\n" + str(e))
        return
    try:
        formats = formats["Headline Formats"]
    except Exception as e:
        g.es_trace("Yaml file does not have proper heading.\n" + str(e))
        return
    #preprocess multi headline styles
    g.app.permanentScriptDict[cs + 'formats'] = {}
    try:
        for k, f in formats.items():
            if "`" in k:
                _ = k.split("`")
                for _1 in _:
                    g.app.permanentScriptDict[cs + 'formats'][_1.strip()] = f
            else:
                g.app.permanentScriptDict[cs + 'formats'][k] = f
    except Exception as e:
        g.es_error(e)
Beispiel #5
0
 def oops(self, p, s):
     '''Give an error message.'''
     g.es_trace('===== %s %s' % (s, p.h), color='red')
Beispiel #6
0
 def oops(self, p, s):
     '''Give an error message.'''
     g.es_trace('===== %s %s' % (s, p.h), color='red')