beacon_aug/generator/docs_generator.py
def replace_alias(function, op_dic, lib_name):
    """Find the source function from alias"""

    if (' alias' in function.__doc__.lower() or 'alias for' in function.__doc__.lower() or "deprecated in favor of" in function.__doc__):

        # (imgaug.PIL)
        if 'Alias for :class:'.lower() in function.__doc__.lower():
            original_fct_name = op_dic[lib_name]["function"]
            new_fct_fullname = function.__doc__.split("See :class:`~")[-1].split("`")[0]
            function = eval(new_fct_fullname)
            return replace_alias(function, op_dic, lib_name)

        elif 'an alias for'.lower() in function.__doc__.lower():
            new_fct_fullname = function.__doc__.split(
                ":class:`~")[-1].split("`")[0]
            function = eval(new_fct_fullname)
            return replace_alias(function, op_dic, lib_name)

        # (torchvision)
        elif "Note: This transform is deprecated in favor of".lower() in function.__doc__.lower():
            original_fct_name = op_dic[lib_name]["function"]
            new_fct_name = function.__doc__.split(
                "deprecated in favor of ")[-1].split(".")[0]
            new_fct_fullname = original_fct_name.replace(
                original_fct_name.split('.')[-1], new_fct_name)
            function = eval(new_fct_fullname)
            return replace_alias(function, op_dic, lib_name)

    return function
Find the source function from alias
Find the source function from alias
Find the source function from alias
def replace_alias(function, op_dic, lib_name):
    if (' alias' in function.__doc__.lower() or 'alias for' in function.__doc__.lower() or "deprecated in favor of" in function.__doc__):
        if 'Alias for :class:'.lower() in function.__doc__.lower():
            original_fct_name = op_dic[lib_name]["function"]
            new_fct_fullname = function.__doc__.split("See :class:`~")[-1].split("`")[0]
            function = eval(new_fct_fullname)
            return replace_alias(function, op_dic, lib_name)
        elif 'an alias for'.lower() in function.__doc__.lower():
            new_fct_fullname = function.__doc__.split(
                ":class:`~")[-1].split("`")[0]
            function = eval(new_fct_fullname)
            return replace_alias(function, op_dic, lib_name)
        elif "Note: This transform is deprecated in favor of".lower() in function.__doc__.lower():
            original_fct_name = op_dic[lib_name]["function"]
            new_fct_name = function.__doc__.split(
                "deprecated in favor of ")[-1].split(".")[0]
            new_fct_fullname = original_fct_name.replace(
                original_fct_name.split('.')[-1], new_fct_name)
            function = eval(new_fct_fullname)
            return replace_alias(function, op_dic, lib_name)
    return function
def replace_alias ( function , op_dic , lib_name ) : if ( ' alias' in function . __doc__ . lower ( ) or 'alias for' in function . __doc__ . lower ( ) or "deprecated in favor of" in function . __doc__ ) : if 'Alias for :class:' . lower ( ) in function . __doc__ . lower ( ) : original_fct_name = op_dic [ lib_name ] [ "function" ] new_fct_fullname = function . __doc__ . split ( "See :class:`~" ) [ - 1 ] . split ( "`" ) [ 0 ] function = eval ( new_fct_fullname ) return replace_alias ( function , op_dic , lib_name ) elif 'an alias for' . lower ( ) in function . __doc__ . lower ( ) : new_fct_fullname = function . __doc__ . split ( ":class:`~" ) [ - 1 ] . split ( "`" ) [ 0 ] function = eval ( new_fct_fullname ) return replace_alias ( function , op_dic , lib_name ) elif "Note: This transform is deprecated in favor of" . lower ( ) in function . __doc__ . lower ( ) : original_fct_name = op_dic [ lib_name ] [ "function" ] new_fct_name = function . __doc__ . split ( "deprecated in favor of " ) [ - 1 ] . split ( "." ) [ 0 ] new_fct_fullname = original_fct_name . replace ( original_fct_name . split ( '.' ) [ - 1 ] , new_fct_name ) function = eval ( new_fct_fullname ) return replace_alias ( function , op_dic , lib_name ) return function
Find the source function from alias
Find the source function from alias
"""Find the source function from alias""" # (imgaug.PIL) # (torchvision)
function
op_dic
lib_name