Skip to content

Commit 62a0797

Browse files
committed
On macOS additionally check /Applications/StataNow
1 parent e9d1c2a commit 62a0797

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed

nbs/01_config.ipynb

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -156,23 +156,25 @@
156156
"def _mac_find_path(_dir=None):\n",
157157
" \"\"\"\n",
158158
" Attempt to find Stata path on macOS when not on user's PATH.\n",
159-
" Modified from stata_kernel's original to only location \"Applications/Stata\". \n",
159+
" Modified from stata_kernel's original to \"/Applications/StataNow\" and \"/Applications/Stata\".\n",
160160
"\n",
161161
" Returns:\n",
162162
" (str): Path to Stata. Empty string if not found.\n",
163163
" \"\"\"\n",
164164
" if _dir is None:\n",
165-
" _dir = '/Applications/Stata'\n",
166-
" path = Path(_dir)\n",
167-
" if not os.path.exists(path):\n",
168-
" return ''\n",
165+
" dirs = [r'/Applications/StataNow',\n",
166+
" r'/Applications/Stata']\n",
169167
" else:\n",
170-
" try:\n",
171-
" # find the application with the suffix .app\n",
172-
" # example path: /Applications/Stata/StataMP.app\n",
173-
" return str(next(path.glob(\"Stata*.app\")))\n",
174-
" except StopIteration:\n",
175-
" return ''"
168+
" dirs = [_dir] \n",
169+
" for this_dir in dirs:\n",
170+
" path = Path(this_dir)\n",
171+
" if os.path.exists(path):\n",
172+
" try:\n",
173+
" # find the application with the suffix .app\n",
174+
" # example path: /Applications/Stata/StataMP.app\n",
175+
" return str(next(path.glob(\"Stata*.app\")))\n",
176+
" except StopIteration:\n",
177+
" return ''"
176178
]
177179
},
178180
{

nbstata/config.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,25 @@ def _win_find_path(_dir=None):
4646
def _mac_find_path(_dir=None):
4747
"""
4848
Attempt to find Stata path on macOS when not on user's PATH.
49-
Modified from stata_kernel's original to only location "Applications/Stata".
49+
Modified from stata_kernel's original to "/Applications/StataNow" and "/Applications/Stata".
5050
5151
Returns:
5252
(str): Path to Stata. Empty string if not found.
5353
"""
5454
if _dir is None:
55-
_dir = '/Applications/Stata'
56-
path = Path(_dir)
57-
if not os.path.exists(path):
58-
return ''
55+
dirs = [r'/Applications/StataNow',
56+
r'/Applications/Stata']
5957
else:
60-
try:
61-
# find the application with the suffix .app
62-
# example path: /Applications/Stata/StataMP.app
63-
return str(next(path.glob("Stata*.app")))
64-
except StopIteration:
65-
return ''
58+
dirs = [_dir]
59+
for this_dir in dirs:
60+
path = Path(this_dir)
61+
if os.path.exists(path):
62+
try:
63+
# find the application with the suffix .app
64+
# example path: /Applications/Stata/StataMP.app
65+
return str(next(path.glob("Stata*.app")))
66+
except StopIteration:
67+
return ''
6668

6769
# %% ../nbs/01_config.ipynb 12
6870
def _other_find_path():

0 commit comments

Comments
 (0)