Skip to content

Commit

Permalink
better deal with non-existent nat regdirs
Browse files Browse the repository at this point in the history
  • Loading branch information
schlegelp committed Mar 30, 2021
1 parent e73b286 commit 96013da
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions flybrains/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ def get_nat_regdirs(verbose=False):

# Parse output
outstr = proc.stdout.decode()
path = pathlib.Path(re.search('.*?"(.*?)"', outstr).group(1))
regdirs.append(path)
match = re.search('.*?"(.*?)"', outstr)
if match and match.group(1).strip() != '':
path = pathlib.Path(match.group(1))
regdirs.append(path)

# This is basepath for nat.flybrains
cmd = "regdirs=c('bridgingregistrations', 'mirroringregistrations');system.file('extdata', regdirs, package = 'nat.flybrains')"
Expand All @@ -80,7 +82,7 @@ def get_nat_regdirs(verbose=False):
# If we don't skip then we add the current directory
# `PosixPath('.')` which will lead to A LOT of recursive
# searching
if match.group(1) == '':
if match.group(1).strip() == '':
continue
path = pathlib.Path(match.group(1))
regdirs.append(path)
Expand All @@ -94,8 +96,10 @@ def get_nat_regdirs(verbose=False):

# Parse output
outstr = proc.stdout.decode()
path = pathlib.Path(re.search('.*?"(.*?)"', outstr).group(1))
regdirs.append(path)
match = re.search('.*?"(.*?)"', outstr)
if match and match.group(1).strip() != '':
path = pathlib.Path(match.group(1))
regdirs.append(path)

return regdirs

Expand Down

0 comments on commit 96013da

Please sign in to comment.