Opened 14 years ago
Closed 11 years ago
#2783 closed enhancement (fixed)
Python utililities should support command-line wildcards
Reported by: | Mike Taves | Owned by: | hobu |
---|---|---|---|
Priority: | normal | Milestone: | 1.8.1 |
Component: | Utilities | Version: | svn-trunk |
Severity: | minor | Keywords: | python, glob, gdal_merge, gdalident |
Cc: | antonio |
Description
At present, a command that uses wildcards does not work as expected, for example with gdal_merge.py:
> gdal_merge.py -o test.tif 094a* ERROR 4: `094a*' does not exist in the file system, and is not recognised as a supported dataset name. Traceback (most recent call last): File "C:\PROGRA~1\FWTOOL~1.1\bin\gdal_merge.py", line 358, in ? ulx = file_infos[0].ulx IndexError: list index out of range
The present workaround is to use batch files and additional parameters (e.g., http://n2.nabble.com/gdal_merge-multiple-files-td2032804.html).
There are two solutions that should be used for all Python command line utilities:
- glob module, which was introduced in Python 2.5
- fnmatch module, introduced pre Python 2.2 (not sure when)
Attachments (2)
Change History (10)
by , 14 years ago
Attachment: | gdal_merge.py.patch added |
---|
comment:1 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:2 by , 14 years ago
Keywords: | gdal_merge gdalident added; fnmatch removed |
---|---|
Milestone: | 1.6.1 → 1.6.3 |
Resolution: | fixed |
Status: | closed → reopened |
Type: | defect → enhancement |
Version: | 1.6.0 → svn-trunk |
I've reviewed my comments and submission, and I'd like to improve on it. I was misinformed about the glob module, in that I misread it was introduced in Python 2.5. The glob module was actually introduced in Python <=2.3 (I'm not sure how to check this history). The glob module really helps wildcard expansions, and should be used in place of fnmatch due to its ease of use.
I have also learned that wildcard expansion is only needed for MS-DOS BAT files. Of course, this is still of valid importance for many users.
Nevertheless, I've included a patch "glob_patch2.diff" using "svn diff" for both gdal_merge.py and gdalident.py. These have been tested in MS-DOS and Linux. It is also much more simpler to read than the previous patch.
by , 14 years ago
Attachment: | glob_patch2.diff added |
---|
improvements to gdal_merge.py and gdalident.py using python glob module
comment:3 by , 14 years ago
Owner: | changed from | to
---|---|
Status: | reopened → new |
comment:4 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:5 by , 13 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Howard,
Globbing of arguments to gdal_merge.py or any other scripts by default is inappropriate as some objects are not in the filesystem as detailed in:
http://lists.osgeo.org/pipermail/gdal-dev/2010-March/023830.html
I think the globbing needs to be backed out or only applied when a -glob or -wildcard switch is passed in.
comment:6 by , 13 years ago
Cc: | added |
---|
comment:7 by , 11 years ago
As above, and per (#4542) this auto-globbing breaks non-simple files. I will apparently have to back it out myself.
comment:8 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
patch for gdal_merge.py using fnmatch solution