Exemple #1
0
def transform_source(source, callback_params=None, **kwargs):
    """This function is called by the import hook loader and is used as a
    wrapper for the function where the real transformation is performed.
    """
    if callback_params["show_original"]:
        utils.print_source(source, "Original")

    source = automatic_self(source)

    if callback_params["show_transformed"]:
        utils.print_source(source, "Transformed")

    return source
Exemple #2
0
def transform_source(source, callback_params=None, **kwargs):
    """This function is called by the import hook loader and uses
    transformations from two other examples.
    """
    if callback_params["show_original"]:
        utils.print_source(source, "Original")

    source = french.french_to_english(source)
    source = repeat.convert_repeat(source)

    if callback_params["show_transformed"]:
        utils.print_source(source, "Transformed")

    return source
Exemple #3
0
def transform_source(source, callback_params=None, **kwargs):
    """This function is called by the import hook loader and is used as a
    wrapper for the function where the real transformation is performed.
    """
    if callback_params["show_original"]:
        utils.print_source(source, "Original")

    source = convert_repeat(
        source, predictable_names=callback_params["predictable_names"])

    if callback_params["show_transformed"]:
        utils.print_source(source, "Transformed")

    return source
Exemple #4
0
def transform_source(source, callback_params=None, **kwargs):
    """This function is called by the import hook loader with the named keyword
       that we specified when we created the import hook.

       It gives us the option to compare the original source and the transformed
       one. This type of additional option can be useful when debugging
       a source transformer. Furthermore, if we wish to define a source
       transformation that combines the effect of multiple existing
       transformations, we can combine the existing "inner" functions to
       create our new transformation.
    """
    if callback_params["show_original"]:
        utils.print_source(source, "Original")

    source = nobreak_as_a_keyword(source)

    if callback_params["show_transformed"]:
        utils.print_source(source, "Transformed")
    return source