Changeset 5022


Ignore:
Timestamp:
Feb 12, 2008, 2:37:03 PM (16 years ago)
Author:
ole
Message:

Added cairns license stub and fixed problem with empty xml tags.

Location:
anuga_core
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/documentation/user_manual/demos/cairns/cairns.lic

    r5021 r5022  
    99    <filename>cairns.asc</filename>
    1010    <checksum>88429353</checksum>
    11     <publishable>No</publishable>
     11    <publishable></publishable>
    1212    <accountable>Jane Sexton</accountable>
    1313    <source>where did it come from?</source>
     
    1919    <filename>cairns.prj</filename>
    2020    <checksum>-2029103677</checksum>
    21     <publishable>No</publishable>
     21    <publishable></publishable>
    2222    <accountable>Jane Sexton</accountable>
    2323    <source></source>
  • anuga_core/source/anuga/utilities/data_audit.py

    r5021 r5022  
    8282            try:
    8383                license_file_is_valid(fid, datafile, dirpath,
    84                                       verbose=verbose)
     84                                      verbose=False)
    8585            except audit_exceptions, e:
    8686                all_files_accounted_for = False                               
     
    311311            raise NotPublishable, msg
    312312       
    313         print 'PUB', publishable
    314313        if publishable.upper() != 'YES':
    315314            msg = 'Data file %s is not flagged as publishable'\
  • anuga_core/source/anuga/utilities/test_xml_tools.py

    r5015 r5022  
    132132
    133133
     134
     135
     136    def test_xml2object_empty_fields(self):
     137        """Test that XML_document can be generated from file
     138        This on tests that empty fields are treated as ''
     139        """
     140
     141        tmp_fd , tmp_name = mkstemp(suffix='.xml', dir='.')
     142        fid = os.fdopen(tmp_fd, 'w')
     143       
     144        xml_string = """<?xml version="1.0" encoding="iso-8859-1"?>
     145  <ga_license_file>
     146    <metadata>
     147      <author>Ole Nielsen</author>
     148      <svn_keywords>
     149        <author>$Author$</author> 
     150        <date>$Date$</date>
     151        <revision>$Revision$</revision>
     152        <url>$URL:$</url>
     153        <id>$Id$</id>
     154      </svn_keywords>
     155    </metadata>
     156    <datafile>
     157      <filename>bathymetry.asc</filename>
     158      <checksum>%s</checksum>
     159      <publishable></publishable>
     160      <accountable>Jane Sexton</accountable>
     161      <source>Unknown</source>
     162      <IP_owner>Geoscience Australia</IP_owner>
     163      <IP_info>This is a test</IP_info>
     164    </datafile>
     165  </ga_license_file>
     166""" %('1234')
     167
     168        fid.write(xml_string)
     169        fid.close()
     170
     171        fid = open(tmp_name)
     172        reference = fid.read()
     173        reflines = reference.split('\n')
     174       
     175        xmlobject = xml2object(fid, verbose=True)
     176
     177
     178        #print xmlobject.pretty_print()
     179       
     180        xmllines = str(xmlobject).split('\n')
     181
     182        #for line in reflines:
     183        #    print line
     184        #print   
     185        #for line in xmllines:
     186        #    print line           
     187
     188           
     189        ##assert len(reflines) == len(xmllines)
     190        x = xmlobject['ga_license_file']['datafile']['publishable']
     191        msg = 'Got %s, should have been an empty string' %x
     192        assert x == '', msg
     193       
     194
     195        for i, refline in enumerate(reflines):
     196            msg = '%s != %s' %(refline.strip(), xmllines[i].strip())
     197            assert refline.strip() == xmllines[i].strip(), msg
     198
     199        # Check dictionary behaviour   
     200        for tag in xmlobject['ga_license_file'].keys():
     201            xmlobject['ga_license_file'][tag]
     202
     203        assert xmlobject['ga_license_file']['datafile']['accountable'] == 'Jane Sexton'
     204
     205
     206       
     207
     208        #print
     209        #print xmlobject['ga_license_file']['datafile']
     210        #print xmlobject['ga_license_file']['metadata']
     211        #print xmlobject['ga_license_file']['datafile']
     212        #print xmlobject['ga_license_file']['datafile']['accountable']       
     213        #print xmlobject['ga_license_file']['datafile'].keys()
     214
     215        #for tag in xmlobject['ga_license_file'].keys():
     216        #    print xmlobject['ga_license_file'][tag]
     217               
     218        # Clean up
     219        fid.close()
     220        os.remove(tmp_name)
     221
     222
    134223       
    135224
  • anuga_core/source/anuga/utilities/xml_tools.py

    r5020 r5022  
    168168        for node in self.value:
    169169            if node.tag == key:
     170                #print 'node tag = %s, node value = %s' %(node.tag, node.value)
     171               
    170172                if isinstance(node.value, basestring):
    171173                    result.append(str(node.value))
     
    174176                    result.append(node)
    175177                    #return node
    176                    
     178
     179        #print 'result', result
    177180        if len(result) == 0:
    178181            return None
     
    255258    for n in node.childNodes:
    256259
    257         #print 'Node name: "%s",' %n.nodeName,\
    258         #      'Node type: "%s",' %n.nodeType,\
    259         #      'Node value: "%s",' %str(n.nodeValue).strip(),\
    260         #      'Node children: %d' %len(n.childNodes)       
    261 
    262260        if n.nodeType == 3:
    263261            # Child is a text element - omit the dom tag #text and
     
    275273            value = x
    276274        else:
     275            # XML element
     276
    277277            value.append(dom2object(n))
    278278
    279 
    280 
     279               
     280    # Deal with empty elements
     281    if len(value) == 0: value = ''
     282   
    281283
    282284    if node.nodeType == 9:
     
    292294       
    293295    return X
     296
     297
     298
     299
     300
     301    #=================== Useful print statement
     302    #if n.nodeType == 3 and str(n.nodeValue).strip() == '':
     303    #    pass
     304    #else:
     305    #    print 'Node name: "%s",' %n.nodeName,\
     306    #          'Node type: "%s",' %n.nodeType,\
     307    #          'Node value: "%s",' %str(n.nodeValue).strip(),\
     308    #          'Node children: %d' %len(n.childNodes)       
Note: See TracChangeset for help on using the changeset viewer.