'Given a Python expression or function body, compile it as a path
field function. The returned function takes a single argument, an
Item, and returns a Unicode string. If the expression cannot be
compiled, then an error is logged and this function returns None.'

def compile_inline(self, python_code, album):

    try:
        code = compile(u'({0})'.format(python_code), 'inline', 'eval')
    except SyntaxError:
        try:
            func = _compile_func(python_code)
        except SyntaxError:
            self._log.error(u'syntax    error    in    inline    field    definition:\n{0}', traceback.format_exc())
            return
        else:
            is_expr = False
    else:
        is_expr = True
    def _dict_for(obj):
        out = dict(obj)
        if album:
            out['items'] = list(obj.items())
        return out
    if is_expr:
        def _expr_func(obj):
            values = _dict_for(obj)
            try:
                return eval(code, values)
            except Exception as exc:
                raise InlineError(python_code, exc)
        return _expr_func
    else:
        def _func_func(obj):
            func.__globals__.update(_dict_for(obj))
            try:
                return func()
            except Exception as exc:
                raise InlineError(python_code, exc)
        return _func_func
