Skip to content

Commit e092a1f

Browse files
authored
Merge pull request #238 from sandialabs/fix_driver_docstring
fix(driver): doc string if not found returns blank. If multiple, tak…
2 parents f3b911f + aa329c6 commit e092a1f

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

pyscan/drivers/instrument_driver.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -433,20 +433,29 @@ def get_property_docstring(self, prop_name):
433433

434434
doc = self.__doc__.split('\n')
435435

436-
r = re.compile(" {} :".format(prop_name))
437-
match = list(filter(r.match, doc))
436+
r = " {} :".format(prop_name)
438437

439-
assert len(match) > 0, "No matches for {} documentation".format(prop_name)
440-
assert len(match) == 1, "Too many matches for {} documentation".format(prop_name)
441-
match = match[0]
438+
def find_match(str):
439+
if r in str:
440+
return True
441+
else:
442+
return False
443+
444+
match = list(filter(find_match, doc))
442445

446+
assert not len(match) > 1, "Too many matches for {} documentation".format(prop_name)
447+
448+
if len(match) == 0:
449+
match = ''
450+
else:
451+
match = match[0]
443452
for i, string in enumerate(doc):
444453
if string == match:
445454
break
446455

447456
doc_string = doc[i][4::]
448457

449-
for j in range(len(doc_string)):
458+
for j in range(len(doc)):
450459
try:
451460
doc[i + 1 + j]
452461
except:

0 commit comments

Comments
 (0)