Shared Memory Dictionary utilizing Posix IPC semaphores and shared memory segments and offering permanent disk storage of data if required.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

extract_source.py 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. )