refined docstr parsing for builtins, because psycopg2 didn't run, even so I thought it would.

This commit is contained in:
David Halter
2012-09-03 14:33:16 +02:00
parent c725b6624b
commit 1775843e23
2 changed files with 7 additions and 4 deletions

View File

@@ -378,14 +378,15 @@ def parse_function_doc(func):
end = 0
param_str = ''
try:
index = doc.index('-> ', end, end + 7)
except (ValueError, AttributeError):
if doc is not None:
r = re.search('-[>-]* ', doc[end:end+7])
if doc is None or r is None:
ret = 'pass'
else:
index = end + r.end()
# get result type, which can contain newlines
pattern = re.compile(r'(,\n|[^\n-])+')
ret_str = pattern.match(doc, index + 3).group(0).strip()
ret_str = pattern.match(doc, index).group(0).strip()
# New object -> object()
ret_str = re.sub(r'[nN]ew (.*)', r'\1()', ret_str)