#NEWLINE# def main( ) : #NEWLINE# #INDENT# topDirectory = 'C:\\temp\\editaxonomy20110314' #NEWLINE# testcaseName = 'EDInet test cases' #NEWLINE# ownerName = 'Hugh Wallis' #NEWLINE# ownerEmail = 'hughwallis@xbrl.org' #NEWLINE# entryRelativeFilePaths = [ ] #NEWLINE# for ( root , dirs , files ) in os . walk ( topDirectory ) : #NEWLINE# #INDENT# for fileName in files : #NEWLINE# #INDENT# if fnmatch . fnmatch ( fileName , '*.xsd' ) : #NEWLINE# #INDENT# fullFilePath = os . path . join ( root , fileName ) #NEWLINE# entryRelativeFilePaths . append ( os . path . relpath ( fullFilePath , topDirectory ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# lines = [ '<?xml version="1.0" encoding="UTF-8"?>' , '<!-- Copyright 2011 XBRL International.  All Rights Reserved. -->' , '<?xml-stylesheet type="text/xsl" href="http://www.xbrl.org/Specification/formula/REC-2009-06-22/conformance/infrastructure/test.xsl"?>' , '<testcase name="{0}" date="{1}" ' . format ( testcaseName , datetime . date . today ( ) ) , ' xmlns="http://xbrl.org/2008/conformance"' , ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' , ' xsi:schemaLocation="http://xbrl.org/2008/conformance http://www.xbrl.org/Specification/formula/REC-2009-06-22/conformance/infrastructure/test.xsd">' , '  <creator>' , '  <name>{0}</name>' . format ( ownerName ) , '  <email>{0}</email>' . format ( ownerEmail ) , '  </creator>' , '  <name>{0}</name>' . format ( ownerEmail ) , '  <description>{0}</description>' . format ( testcaseName ) ] #NEWLINE# num = 1 #NEWLINE# for entryFile in entryRelativeFilePaths : #NEWLINE# #INDENT# fileName = os . path . basename ( entryFile ) #NEWLINE# lines . append ( "  <variation name='{0}' id='V-{1}'>" . format ( fileName , num ) ) #NEWLINE# num += 1 #NEWLINE# lines . append ( '    <description>{0}</description>' . format ( fileName ) ) #NEWLINE# lines . append ( '    <data>' ) #NEWLINE# lines . append ( "       <xsd readMeFirst='true'>{0}</xsd>" . format ( entryFile . replace ( '\\' , '/' ) ) ) #NEWLINE# lines . append ( '    </data>' ) #NEWLINE# lines . append ( "    <result expected='valid'/>" ) #NEWLINE# lines . append ( '  </variation>' ) #NEWLINE# #UNINDENT# lines . append ( '</testcase>' ) #NEWLINE# with open ( os . path . join ( topDirectory , 'testcase.xml' ) , 'w' ) as fh : #NEWLINE# #INDENT# fh . write ( '\n' . join ( ownerName ) )