Changeset 5022
- Timestamp:
- Feb 12, 2008, 2:37:03 PM (17 years ago)
- Location:
- anuga_core
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/documentation/user_manual/demos/cairns/cairns.lic
r5021 r5022 9 9 <filename>cairns.asc</filename> 10 10 <checksum>88429353</checksum> 11 <publishable> No</publishable>11 <publishable></publishable> 12 12 <accountable>Jane Sexton</accountable> 13 13 <source>where did it come from?</source> … … 19 19 <filename>cairns.prj</filename> 20 20 <checksum>-2029103677</checksum> 21 <publishable> No</publishable>21 <publishable></publishable> 22 22 <accountable>Jane Sexton</accountable> 23 23 <source></source> -
anuga_core/source/anuga/utilities/data_audit.py
r5021 r5022 82 82 try: 83 83 license_file_is_valid(fid, datafile, dirpath, 84 verbose= verbose)84 verbose=False) 85 85 except audit_exceptions, e: 86 86 all_files_accounted_for = False … … 311 311 raise NotPublishable, msg 312 312 313 print 'PUB', publishable314 313 if publishable.upper() != 'YES': 315 314 msg = 'Data file %s is not flagged as publishable'\ -
anuga_core/source/anuga/utilities/test_xml_tools.py
r5015 r5022 132 132 133 133 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 134 223 135 224 -
anuga_core/source/anuga/utilities/xml_tools.py
r5020 r5022 168 168 for node in self.value: 169 169 if node.tag == key: 170 #print 'node tag = %s, node value = %s' %(node.tag, node.value) 171 170 172 if isinstance(node.value, basestring): 171 173 result.append(str(node.value)) … … 174 176 result.append(node) 175 177 #return node 176 178 179 #print 'result', result 177 180 if len(result) == 0: 178 181 return None … … 255 258 for n in node.childNodes: 256 259 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 262 260 if n.nodeType == 3: 263 261 # Child is a text element - omit the dom tag #text and … … 275 273 value = x 276 274 else: 275 # XML element 276 277 277 value.append(dom2object(n)) 278 278 279 280 279 280 # Deal with empty elements 281 if len(value) == 0: value = '' 282 281 283 282 284 if node.nodeType == 9: … … 292 294 293 295 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.