Skip to content

Commit c39b4f9

Browse files
committed
Strip single and double quotes from stata_dir
1 parent b31af9d commit c39b4f9

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

nbs/01_config.ipynb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,12 +426,13 @@
426426
"source": [
427427
"#| export\n",
428428
"def set_pystata_path(stata_dir=None):\n",
429+
" stata_dir = stata_dir.strip('\"\\'')\n",
429430
" if stata_dir is None:\n",
430431
" stata_dir, _ = find_dir_edition()\n",
431432
" if not os.path.isdir(stata_dir):\n",
432-
" raise OSError(f'Specified stata_dir, \"{stata_dir}\", is not a valid directory path')\n",
433+
" raise OSError(f'Specified stata_dir, {stata_dir}, is not a valid directory path')\n",
433434
" if not os.path.isdir(os.path.join(stata_dir, 'utilities')):\n",
434-
" raise OSError(f'Specified stata_dir, \"{stata_dir}\", is not Stata\\'s installation path')\n",
435+
" raise OSError(f'Specified stata_dir, {stata_dir}, is not Stata\\'s installation path')\n",
435436
" sys.path.append(os.path.join(stata_dir, 'utilities'))"
436437
]
437438
},

nbstata/config.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,13 @@ def find_edition(stata_dir):
114114

115115
# %% ../nbs/01_config.ipynb 25
116116
def set_pystata_path(stata_dir=None):
117+
stata_dir = stata_dir.strip('"\'')
117118
if stata_dir is None:
118119
stata_dir, _ = find_dir_edition()
119120
if not os.path.isdir(stata_dir):
120-
raise OSError(f'Specified stata_dir, "{stata_dir}", is not a valid directory path')
121+
raise OSError(f'Specified stata_dir, {stata_dir}, is not a valid directory path')
121122
if not os.path.isdir(os.path.join(stata_dir, 'utilities')):
122-
raise OSError(f'Specified stata_dir, "{stata_dir}", is not Stata\'s installation path')
123+
raise OSError(f'Specified stata_dir, {stata_dir}, is not Stata\'s installation path')
123124
sys.path.append(os.path.join(stata_dir, 'utilities'))
124125

125126
# %% ../nbs/01_config.ipynb 29

0 commit comments

Comments
 (0)