Returns quoted code if not already quoted and if possible

    Parameters
    ----------

    code: String
    \tCode thta is quoted

def quote(code):
    """Returns quoted code if not already quoted and if possible

    Parameters
    ----------

    code: String
    \tCode thta is quoted

    """

    try:
        code = code.rstrip()

    except AttributeError:
        # code is not a string, may be None --> There is no code to quote
        return code

    if code and code[0] + code[-1] not in ('""', "''", "u'", '"') \
       and '"' not in code:
        return 'u"' + code + '"'
    else:
        return code