<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _parseline(line):
 """ Parse a line contains shell variable definition. :param line: A string to parse, must not start with '#' (comment) :return: A tuple of (key, value), both key and value may be None ('aaa', '') ('aaa', 'bbb') ('aaa', 'bb b') ('aaa', 'bb#b') ('aaa', 'bb"b') ('aaa', 'bbb') """

    match = re.match(r"^\s*(export)?\s*(\S+)=(?:(?:"
                     r"(?:\"(.*[^\\])\")|(?:'(.*[^\\])')|"
                     r"(?:([^\"'#\s]+)))?)\s*#*", line)
    if not match:
        LOGGER.warning("Invalid line found: %s", line)
        return (None, None)

    tpl = match.groups()
    vals = list(itertools.dropwhile(lambda x: x is None, tpl[2:]))
    return (tpl[1], vals[0] if vals else '')