Shared Memory Dictionary utilizing Posix IPC semaphores and shared memory segments and offering permanent disk storage of data if required.
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

40 行
1.3KB

  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import os
  4. from bs4 import BeautifulSoup
  5. from bs4.element import Tag as bs4_Tag
  6. __author__ = "Nate Bohman"
  7. __credits__ = ["Nate Bohman"]
  8. __license__ = "LGPL-3"
  9. __maintainer__ = "Nate Bohman"
  10. __email__ = "natrinicle@natrinicle.com"
  11. __status__ = "Production"
  12. COVERAGE_PATH = os.path.abspath(os.path.dirname(__file__))
  13. for filename in os.listdir(COVERAGE_PATH):
  14. if filename.endswith("_py.html"):
  15. # Cut off .html and add .source.html
  16. source_only_filename = "{}.source.html".format(filename[:-5])
  17. with open(os.path.join(COVERAGE_PATH, filename), "r") as file:
  18. soup = BeautifulSoup(file.read(), "html.parser")
  19. source_div = soup.find(id="source")
  20. source_text_td = source_div.find_all("td", {"class": "text"})[0]
  21. with open(
  22. os.path.join(COVERAGE_PATH, source_only_filename), "w"
  23. ) as output_file:
  24. for line in source_text_td.contents:
  25. if isinstance(line, (bs4_Tag)):
  26. try:
  27. output_file.write("{}\n".format(line))
  28. except UnicodeEncodeError:
  29. output_file.write(
  30. "{}\n".format(line)
  31. .encode("ascii", "ignore")
  32. .decode("ascii")
  33. )