def unquote(inline, fullquote = 1, retain = 0, **keywargs):
    """Given a line - if it's correctly quoted - it reurns the 'unquoted' value.
    If not quoted at all, it returns -1.
    If badly quoted, it returns None.
    
    line is stripped before starting.

    Any instances of '&mjf-quot;' found (from elem_quot) are turned back into '"'
    Any instances of '&mjf-lf;' found (from elem_quot) are turned back into '\n'
    
    Quotes can be escaped with a '\'.
    '\' (or any other character) can also be escaped with a '\'.
    No triple quotes though :-)
    (Escaping can be switched off by passing in the keyword argument 'escapechar' set to None
    If you want to use literal '\' without escaping them then you must turn escaping off).

    If fullquote is set to 0 (default is 1)
    then unquote will return the first correctly quoted part of the line *and* the rest of the line.
    If retain is set to 1 (default is 0)
    then unquote will retain the quote characters in the returned value."""
    if keywargs.has_key('escapechar'):
        escapechar = keywargs['escapechar']
    else:
        escapechar = True
    outline = ''
    quotes = ["'",'"']
    escape = 0
    index = 0
    quotechar = None
    inline = inline.strip()
    while index < len(inline):
        thischar = inline[index]
        index += 1
        if not quotechar and thischar not in quotes:
            return -1
        elif not quotechar:
            quotechar = thischar
            if retain:
                outline += thischar
            continue
        if escape:
            outline += thischar
            escape = 0
            continue
        if thischar in quotes:
            if thischar == quotechar:
                if retain:
                    outline += thischar
                if not fullquote:
                    return outline.replace('&mjf-quot;','\"').replace('&mjf-lf;','\n'), inline[index:]
                elif index == len(inline):
                    return outline.replace('&mjf-quot;','\"').replace('&mjf-lf;','\n')
                else:
                    return None
            else:
                outline += thischar
                continue
        if thischar == '\\' and escapechar:         # a continue here to *not* retain the escape character 
            escape = 1
            continue
        outline += thischar
    return None
Given a line - if it's correctly quoted - it reurns the 'unquoted' value.
    If not quoted at all, it returns -1.
    If badly quoted, it returns None.
    
    line is stripped before starting.

    Any instances of '&mjf-quot;' found (from elem_quot) are turned back into '"'
    Any instances of '&mjf-lf;' found (from elem_quot) are turned back into '
'
    
    Quotes can be escaped with a ''.
    '' (or any other character) can also be escaped with a ''.
    No triple quotes though :-)
    (Escaping can be switched off by passing in the keyword argument 'escapechar' set to None
    If you want to use literal '' without escaping them then you must turn escaping off).

    If fullquote is set to 0 (default is 1)
    then unquote will return the first correctly quoted part of the line *and* the rest of the line.
    If retain is set to 1 (default is 0)
    then unquote will retain the quote characters in the returned value.
recipes/Python/281056_Listparse/recipe-281056.py