From 1775843e23227da90c3c135f3cda87fc8606a654 Mon Sep 17 00:00:00 2001 From: David Halter Date: Mon, 3 Sep 2012 14:33:16 +0200 Subject: [PATCH] refined docstr parsing for builtins, because psycopg2 didn't run, even so I thought it would. --- builtin.py | 9 +++++---- test/completion/thirdparty/psycopg2_.py | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/builtin.py b/builtin.py index da3d8be9..419e493f 100644 --- a/builtin.py +++ b/builtin.py @@ -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) diff --git a/test/completion/thirdparty/psycopg2_.py b/test/completion/thirdparty/psycopg2_.py index 89e6f050..834704b3 100644 --- a/test/completion/thirdparty/psycopg2_.py +++ b/test/completion/thirdparty/psycopg2_.py @@ -1,3 +1,5 @@ +import psycopg2 + conn = psycopg2.connect('dbname=test') #? ['cursor']