You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
first of all I would like to thank you for brining so much effort to build such a useful and customizable tool for python notebooks!
I have faced a little issue using the --pipe option. While I convert the .py file to .ipynb I want to append a "open in colab" badge which refers to the notebook in the GH repository.
The temp filenames look like original_filename_randomsuffix.py and I thought I can just rstrip the the temp_filename and take the substring left from last _ to get the basename. However, once I had a suffix of tempfile which contained another underscore in a way the tempfile was like: original_filename_randomsuffix_randomsuffix.py.
Is there any workarounds to get the original name? A possible sollution would be to basically set the suffix for the tempfiles to be constant or either restrict an underscore (really dirty mess).
The text was updated successfully, but these errors were encountered:
lrlunin
changed the title
get the original file name for temp file name
get the original file name from the temp file name
Dec 11, 2024
Okay, this was much more interesting thing then I have expected.
I have expected that python relies on the standard libc and creates the random file with the posix mkstemp() function which generates a temp file with the template filenameXXXXXX where X can be an any alphanumeric (A-Za-z0-9) character.
This contains only lowcase letters, also numbers but also includes an "_" in the list for the allowed characters. This is really not clever to make the behaviour expected to be simillar to mkstemp but then make it not posix conform.
What would you think about to change "_" to any other character ("@", "^" or even ".") which cannot be possibly be within the tempfile name?
Hello,
first of all I would like to thank you for brining so much effort to build such a useful and customizable tool for python notebooks!
I have faced a little issue using the
--pipe
option. While I convert the.py
file to.ipynb
I want to append a "open in colab" badge which refers to the notebook in the GH repository.To do so I use the following pipeline:
while in
insert_badge.py
I have something like:The temp filenames look like
original_filename_randomsuffix.py
and I thought I can just rstrip the thetemp_filename
and take the substring left from last_
to get the basename. However, once I had a suffix of tempfile which contained another underscore in a way the tempfile was like:original_filename_randomsuffix_randomsuffix.py
.Is there any workarounds to get the original name? A possible sollution would be to basically set the suffix for the tempfiles to be constant or either restrict an underscore (really dirty mess).
The text was updated successfully, but these errors were encountered: