def docstring_params(docstring):
def find_line(text):<EOL><INDENT>for index, line in enumerate(docstring):<EOL><INDENT>if line == text:<EOL><INDENT>return index + <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT>def find_params(start):<EOL><INDENT>"""<STR_LIT>"""<EOL>params = OrderedDict()<EOL>if start is None:<EOL><INDENT>return params<EOL><DEDENT>lines = []<EOL>for part in docstring[start:]:<EOL><INDENT>if part == "<STR_LIT:\n>":<EOL><INDENT>break<EOL><DEDENT>if part.startswith("<STR_LIT>"):<EOL><INDENT>lines.append(part[:-<NUM_LIT:1>])<EOL>continue<EOL><DEDENT>lines[-<NUM_LIT:1>] += part[:-<NUM_LIT:1>]<EOL><DEDENT>for line in lines:<EOL><INDENT>match = RE_PARAM.match(line)<EOL>if match:<EOL><INDENT>if match.group("<STR_LIT:value>"):<EOL><INDENT>try:<EOL><INDENT>value = eval(match.group("<STR_LIT:value>"))<EOL>if isinstance(value, str):<EOL><INDENT>try:<EOL><INDENT>value = value.decode("<STR_LIT:utf-8>")<EOL><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>try:<EOL><INDENT>value = value.replace("<STR_LIT>", "<STR_LIT:&>")<EOL>value = value.replace("<STR_LIT>", "<STR_LIT:<>")<EOL>value = value.replace("<STR_LIT>", "<STR_LIT:>>")<EOL><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><DEDENT>value = (value,)<EOL><DEDENT>except (SyntaxError, NameError):<EOL><INDENT>value = "<STR_LIT>"<EOL><DEDENT><DEDENT>else:<EOL><INDENT>value = None<EOL><DEDENT>params[match.group("<STR_LIT:name>")] = value<EOL><DEDENT><DEDENT>return params<EOL><DEDENT>params = find_params(find_line("<STR_LIT>"))<EOL>obsolete = find_params(find_line("<STR_LIT>"))<EOL>return params, obsolete<EOL>
Crudely parse the docstring and get parameters and their defaults