Skip to content

Commit

Permalink
fix(driver): doc string if not found returns blank. If multiple, take…
Browse files Browse the repository at this point in the history
…s first
  • Loading branch information
ammounce committed Nov 4, 2024
1 parent 488b33a commit f723504
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions pyscan/drivers/instrument_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,13 +433,22 @@ def get_property_docstring(self, prop_name):

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

r = re.compile(" {} :".format(prop_name))
match = list(filter(r.match, doc))
r = " {} :".format(prop_name)

assert len(match) > 0, "No matches for {} documentation".format(prop_name)
assert len(match) == 1, "Too many matches for {} documentation".format(prop_name)
match = match[0]
def find_match(str):
if r in str:
return True
else:
return False

match = list(filter(find_match, doc))

assert not len(match) > 1, "Too many matches for {} documentation".format(prop_name)

if len(match) == 0:
match = ''
else:
match = match[0]
for i, string in enumerate(doc):
if string == match:
break
Expand Down

0 comments on commit f723504

Please sign in to comment.