Opened 21 years ago

Last modified 20 years ago

#413 closed defect (worksforme)

python binding for GetMetadata() fails when value contains '='

Reported by: richarda@… Owned by: warmerdam
Priority: high Milestone:
Component: default Version: unspecified
Severity: normal Keywords:
Cc:

Description

I am trying to use gdal python binding to work with MODIS
(http://modarch.gsfc.nasa.gov) satellite imagery (HDF4) files. These files
contain text file attributes which are very long (20kB-40kB typically). 
Some attributes are multiline metadata files with many lines of the form 
'KEYWORD = VALUE'.

GDAL (1.1.9) python bindings fail (wrong result) when parsing these metadata
entries. I expect it is a side effect of using a text 'name=value'
implementation, as the first '=' character would throw the whole parser into a
spin. As such it would not be limited to just python. I have not tested other
bindings.

Attachments (1)

tmp_coremetadata.0.txt (15.5 KB ) - added by richarda@… 21 years ago.
value of attribute named 'CoreMetadata.0'

Download all attachments as: .zip

Change History (5)

comment:1 by warmerdam, 21 years ago

Richard, 

I have tried to reproduce this problem producing my own metadata and reading
it back in a Python script but everything seemed to work fine. 

Could you point me to an HDF file that reproduces the problem, and give me
a snipped of code to demonstrate it? 

I used this script which seemed to work fine. 

#!/usr/bin/env python

import gdal

ds = gdal.Open('metawrk.tif',gdal.GA_Update)

value = 'def=%s\nghi=%s' % ('abc','123')
md = { 'key' : value }

ds.SetMetadata( md )

ds = None

ds = gdal.Open('metawrk.tif',gdal.GA_Update)

print ds.GetMetadata()

ds = None


by richarda@…, 21 years ago

Attachment: tmp_coremetadata.0.txt added

value of attribute named 'CoreMetadata.0'

comment:2 by richarda@…, 21 years ago

The attachment for 'CoreMetadata.0' is a long multi-lined ODL file. This entire
text file is the value of the attribute named 'CoreMetadata.0' of type char.

comment:3 by warmerdam, 21 years ago

Richard, 

I saved your attachment to a text file, and used it as the "value" in my
little python script and it seemed to work properly.  I am not convinced the
issue is the core metadata handling code in C or in the python bindings.  

comment:4 by warmerdam, 20 years ago

Without more information I am unable to reproduce this.  Closing the bug report.
If you can reproduce with the gdal 1.2.0a code base then please reopen the
bug report with details. 

Note: See TracTickets for help on using tickets.