OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/python |
| 2 import os, re, os.path, glob |
| 3 |
| 4 head = re.compile( r"^(\s*</head>)", re.MULTILINE ) |
| 5 runtest = re.compile( r"runTest\(\s*(\S.*?)\s*\)", re.DOTALL ) |
| 6 |
| 7 scripts = ''' |
| 8 <!-- Polyfill files (NOTE: These are added by auto-generation script) --> |
| 9 <script src=/encrypted-media/polyfill/chrome-polyfill.js></script> |
| 10 <script src=/encrypted-media/polyfill/firefox-polyfill.js></script> |
| 11 <script src=/encrypted-media/polyfill/edge-persistent-usage-record.js></scri
pt> |
| 12 <script src=/encrypted-media/polyfill/edge-keystatuses.js></script> |
| 13 <script src=/encrypted-media/polyfill/clearkey-polyfill.js></script>''' |
| 14 |
| 15 def process_file( infile, outfile ) : |
| 16 with open( outfile, "w" ) as output : |
| 17 with open( infile, "r" ) as input : |
| 18 output.write( runtest.sub( r"runTest( \1, 'polyfill: ' )", head.sub(
scripts + r"\1", input.read() ) ) ) |
| 19 |
| 20 if __name__ == '__main__' : |
| 21 if (not os.getcwd().endswith('polyfill')) : |
| 22 print "Please run from polyfill directory" |
| 23 exit( 1 ) |
| 24 |
| 25 for infile in glob.glob( "../*.html" ) : |
| 26 process_file( infile, os.path.basename( infile ) ) |
| 27 |
| 28 for infile in glob.glob( "../resources/*.html" ) : |
| 29 process_file( infile, os.path.join( "resources", os.path.basename( infil
e ) ) ) |
OLD | NEW |