(func=None, alias=None)
Expose the function or class.

    Optionally provide an alias or set of aliases.
Expose the function or class.
Expose the function or class .
def expose(func=None, alias=None):
    """Expose the function or class.

    Optionally provide an alias or set of aliases.
    """
    def expose_(func):
        func.exposed = True
        if alias is not None:
            if isinstance(alias, text_or_bytes):
                parents[alias.replace('.', '_')] = func
            else:
                for a in alias:
                    parents[a.replace('.', '_')] = func
        return func

    import sys
    import types
    decoratable_types = types.FunctionType, types.MethodType, type,
    if isinstance(func, decoratable_types):
        if alias is None:
            # @expose
            func.exposed = True
            return func
        else:
            # func = expose(func, alias)
            parents = sys._getframe(1).f_locals
            return expose_(func)
    elif func is None:
        if alias is None:
            # @expose()
            parents = sys._getframe(1).f_locals
            return expose_
        else:
            # @expose(alias="alias") or
            # @expose(alias=["alias1", "alias2"])
            parents = sys._getframe(1).f_locals
            return expose_
    else:
        # @expose("alias") or
        # @expose(["alias1", "alias2"])
        parents = sys._getframe(1).f_locals
        alias = func
        return expose_
def expose ( func = None , alias = None ) : def expose_ ( func ) : func . exposed = True if alias is not None : if isinstance ( alias , text_or_bytes ) : parents [ alias . replace ( '.' , '_' ) ] = func else : for a in alias : parents [ a . replace ( '.' , '_' ) ] = func return func import sys import types decoratable_types = types . FunctionType , types . MethodType , type , if isinstance ( func , decoratable_types ) : if alias is None : # @expose func . exposed = True return func else : # func = expose(func, alias) parents = sys . _getframe ( 1 ) . f_locals return expose_ ( func ) elif func is None : if alias is None : # @expose() parents = sys . _getframe ( 1 ) . f_locals return expose_ else : # @expose(alias="alias") or # @expose(alias=["alias1", "alias2"]) parents = sys . _getframe ( 1 ) . f_locals return expose_ else : # @expose("alias") or # @expose(["alias1", "alias2"]) parents = sys . _getframe ( 1 ) . f_locals alias = func return expose_