Ticket #32 (closed enhancement: invalid)

Opened 4 years ago

Last modified 5 months ago

[PATCH] Determine the path of notebook (pyw) file from within the notebook file.

Reported by: jonkuhn Assigned to: jonkuhn
Priority: low Keywords:
Cc:

Description

I use Reinteract to analyze CSV data files which are stored in the same directory as the script I am using to analyze them (or at least a path relative to the directory the script is stored in). Therefore, to load these CSV files it is useful for me to access the path the notebook file is stored in, in order to locate the associated CSV file. This patch allows the path of the notebook file to be accessed like this:

__reinteract_notebook.get_path()[0]

Attachments

0001-Added-get_path-method-to-notebook.py-so-that-the-loa.patch (1.2 kB) - added by jonkuhn on 03/12/08 16:53:27.
patch generated by git format-patch

Change History

03/12/08 16:53:27 changed by jonkuhn

  • attachment 0001-Added-get_path-method-to-notebook.py-so-that-the-loa.patch added.

patch generated by git format-patch

03/12/08 16:54:15 changed by jonkuhn

  • summary changed from Determine the path of notebook (pyw) file from within the notebook file. to [PATCH] Determine the path of notebook (pyw) file from within the notebook file..

08/10/08 22:57:26 changed by otaylor

No surprise, I think, that I'm not going to accept the patch in that form. :-) To begin with, I think I'd want something like notebook.set_data_path(), notebook.data_path rather than assuming that the first element in path is the place to find data files. But beyond that, I think that we should make this easy on the user, since it will likely be a common thing to do.

Two ideas, not mutually exclusive

* Override open in the worksheet's global scope with a function that resolves relative paths to the notebook. This clearly doesn't help if you are using a CVS-parsing library that wants a filename.

* Make it more explicit:

import reinteract.fileutils as fileutils

filename = fileutils.find_file('foo.csv')

or much simpler:

* while the notebook is executing simply make the notebook's top level directory the current working directory for the script.

09/17/11 15:14:00 changed by otaylor

  • status changed from new to closed.
  • resolution set to invalid.

Moved to https://bugzilla.gnome.org/show_bug.cgi?id=659342, closing as "invalid"