Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix base directory #21

Merged
merged 1 commit into from
Jul 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions nbsearch/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
]


def _get_root_dir(nb_server_app):
if hasattr(nb_server_app, 'root_dir'):
return nb_server_app.root_dir
return nb_server_app.notebook_dir


def get_api_handlers(parent_app, base_dir):
db = NBSearchDB(parent=parent_app)

Expand All @@ -34,9 +40,11 @@ def get_api_handlers(parent_app, base_dir):

def register_routes(nb_server_app, web_app):
from notebook.utils import url_path_join
api_handlers = get_api_handlers(nb_server_app, nb_server_app.notebook_dir)
base_dir = _get_root_dir(nb_server_app)
nb_server_app.log.info(f'nbsearch extension: base_dir={base_dir}')
api_handlers = get_api_handlers(nb_server_app, base_dir)

nbsearchignore = os.path.join(nb_server_app.notebook_dir, '.nbsearchignore')
nbsearchignore = os.path.join(base_dir, '.nbsearchignore')
if not os.path.exists(nbsearchignore):
with open(nbsearchignore, 'w') as f:
f.write(f'''# Generated by nbsearch
Expand Down