-
-
Notifications
You must be signed in to change notification settings - Fork 309
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
g.tempfile: allow creation of temporary directories #4397
base: main
Are you sure you want to change the base?
Conversation
@@ -52,6 +53,13 @@ int main(int argc, char *argv[]) | |||
dry_run->description = | |||
_("Dry run - don't create a file, just prints it's file name"); | |||
|
|||
directory = G_define_flag(); | |||
directory->key = 'f'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d is unfortunately used, but f is not great: folder, file, or directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I felt the same but had no better idea. I considered -D
but that did not seem better than -f
for folder mode...
Any suggestions?
Are the requested changes sufficiently addressed? Any suggestions for a different flag-key? I had and have unfortunately no better idea than -f (or -D, in case)... Would be happy to get this merged... |
I think anything will be better than -f. If the main use of this interface is shell scripting, -f to mean directory/folder as opposed to file is highly unexpected. From letters which come to my mind and don't have other possible meaning here, I suggest u and m. No particular reason for those. An option like |
If the size of temporary files is not an issue, it is recommended | ||
to use <i>NamedTemporaryFile</i> with a context manager to create a | ||
temporary file in Python.<br> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be clear, you can pass dir to both NamedTemporaryFile and TemporaryDirectory, so you can (could) use the 100% way with the project-based tmp dir if you get the project-mapset-hostname path in some way even without creating subdirectories there.
It is designed for shell scripts that need to use large temporary files. | ||
GRASS provides a mechanism for temporary files or directories that does not | ||
depend on /tmp. GRASS temporary files and directories are created in the | ||
GRASS GIS database with the assumption that there will be enough space for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can consider talking only about the project. See #3121 Phase 3, bullet point De-emphasize GISDBASE as its own thing from user perspective.
GRASS GIS database with the assumption that there will be enough space for | |
GRASS GIS project with the assumption that there will be enough space for |
You anyway specify only $PROJECT below.
GRASS provides a mechanism for temporary files or directories that does not | ||
depend on /tmp. GRASS temporary files and directories are created in the | ||
GRASS GIS database with the assumption that there will be enough space for | ||
large files. The base directory is: $PROJECT/$MAPSET/.tmp/$HOSTNAME/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it is clear to the reader what host name is. Elsewhere we talk about node or node name. Hard to say, maybe it's fine as is.
The Python library has a function to create temporary directories: https://grass.osgeo.org/grass84/manuals/libpython/_modules/script/core.html#tempdir
The underlying C-module however does not support that. This PR allows the
g.tempfile
module to create a temporary directory instead of a temporary file. The functionality is equal to the function in the Python library and the python library is updated to use the new f-flag ing.tempfile
.