<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def parse_rst_index(rstpth):
 """ Parse the top-level RST index file, at `rstpth`, for the example python scripts. Returns a list of subdirectories in order of appearance in the index file, and a dict mapping subdirectory name to a description. """


    pthidx = {}
    pthlst = []
    with open(rstpth) as fd:
        lines = fd.readlines()
    for i, l in enumerate(lines):
        if i > 0:
            if re.match(r'^  \w+', l) is not None and \
               re.match(r'^\w+', lines[i - 1]) is not None:
                # List of subdirectories in order of appearance in index.rst
                pthlst.append(lines[i - 1][:-1])
                # Dict mapping subdirectory name to description
                pthidx[lines[i - 1][:-1]] = l[2:-1]
    return pthlst, pthidx