Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. import re
  2. import os
  3.  
  4. paths = [
  5. "testing/web-platform/tests/eventsource/shared-worker/eventsource-constructor-url-bogus.htm",
  6. "testing/web-platform/tests/eventsource/shared-worker/eventsource-onmesage.htm",
  7. "testing/web-platform/tests/eventsource/shared-worker/eventsource-eventtarget.htm",
  8. "testing/web-platform/tests/eventsource/shared-worker/eventsource-onopen.htm",
  9. "testing/web-platform/tests/eventsource/shared-worker/eventsource-close.htm",
  10. "testing/web-platform/tests/eventsource/shared-worker/eventsource-url.htm",
  11. "testing/web-platform/tests/eventsource/shared-worker/eventsource-prototype.htm",
  12. "testing/web-platform/tests/eventsource/dedicated-worker/eventsource-constructor-url-bogus.htm",
  13. "testing/web-platform/tests/eventsource/dedicated-worker/eventsource-onopen.htm",
  14. # .... rg -F "Worker('"
  15. ]
  16.  
  17. for path in paths:
  18. print path
  19.  
  20. path = "/home/tom/projects/central/" + path
  21. f = open(path)
  22. data = f.read()
  23.  
  24.  
  25. before, after = re.split("\<\!doctype html\>", data, 0, re.I)
  26.  
  27. javascript = before.strip().strip("<>!-\n/*")
  28. html = "<!doctype html>" + after.split("<!--")[0].rstrip()
  29.  
  30. new = re.sub("\.html?", ".js", path)
  31.  
  32. html = html.replace("Worker('#')", "Worker('" + os.path.basename(new) + "')")
  33.  
  34. open(path, "w").write(html)
  35.  
  36. print new
  37. assert not os.path.exists(new)
  38.  
  39. open(new, "w").write(javascript)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement