Changeset 348
- Timestamp:
- 08/31/10 11:17:30
- Files:
-
- spongenet/trunk/spongenet/expand.py (modified) (4 diffs)
- spongenet/trunk/spongenet/tests/expand/xmlref/2010_04/20100429T000300-20100429T002730.ref (modified) (previous)
- spongenet/trunk/spongenet/tests/expand/xmlref/2010_04/20100429T002800-20100429T005230.ref (modified) (previous)
- spongenet/trunk/spongenet/tests/expand/xmlref/2010_05/20100501T002258-20100501T004728.ref (modified) (previous)
- spongenet/trunk/spongenet/tests/expand/xmlref/2010_05/20100501T004758-20100501T011228.ref (modified) (previous)
- spongenet/trunk/spongenet/tests/expand/xmlref/2010_06/20100630T231441-20100630T233911.ref (modified) (previous)
- spongenet/trunk/spongenet/tests/expand/xmlref/2010_06/20100630T233941-20100701T000411.ref (modified) (previous)
- spongenet/trunk/spongenet/tests/expand/xmlref/2010_07/20100701T000441-20100701T002911.ref (modified) (previous)
- spongenet/trunk/spongenet/tests/expand/xmlref/2010_07/20100701T002941-20100701T005411.ref (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
spongenet/trunk/spongenet/expand.py
r345 r348 244 244 def combine(xml_subdir, xmlfile_pattern): 245 245 """ 246 Combine the xmlsponge data files from a subdirectory.246 Combine the XML sponge data files from a subdirectory. 247 247 248 248 Combine test subdirectory. … … 278 278 """ 279 279 280 # Find all the xmlsponge data files.280 # Find all the XML sponge data files. 281 281 xmlfiles = glob.glob(os.path.join(xml_subdir, xmlfile_pattern)) 282 282 xmlfiles = [xmlfile … … 284 284 if os.path.isfile(xmlfile)] 285 285 286 # Read all the xmlsponge data files.286 # Read all the XML sponge data files. 287 287 files = fileinput.FileInput(xmlfiles) 288 header = files.readline() 289 lines = [ "\r\n" if files.isfirstline() else line for line in files]290 291 # Write a combined xmlsponge data file.288 header = files.readline().rstrip() + "\n" 289 lines = [line.rstrip() + "\n" for line in files if not files.isfirstline()] 290 291 # Write a combined XML sponge data file. 292 292 path = xml_subdir + os.extsep + "xml" 293 293 with open(path, "w") as handle: 294 294 handle.write(header) 295 handle.write("<root>\ r\n")295 handle.write("<root>\n") 296 296 handle.writelines(lines) 297 handle.write(" \r\n</root>")298 299 # Remove the xmlsponge data file subdirectory.297 handle.write("</root>\n") 298 299 # Remove the XML sponge data file subdirectory. 300 300 shutil.rmtree(xml_subdir) 301 301 … … 374 374 if not os.path.exists(xml_subdir): 375 375 os.mkdir(xml_subdir, 0755) 376 # Extract all the xml files in the zip file. 376 # Extract all the XML files in the zip file 377 # and combine into a single XML document. 377 378 archive = zipfile.ZipFile(zip_file, "r") 378 379 archive.extractall(xml_subdir)