GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — java-profiler/.github/scripts/python_utils.py at main · DataDog/java-profiler

Expand file tree

/

python_utils.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
59 lines (51 loc) · 1.87 KB
/

python_utils.py

Copy path

File metadata and controls

59 lines (51 loc) · 1.87 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import sys
from bs4 import BeautifulSoup
def remove_tags(soup, tags_to_remove):
for tag in tags_to_remove:
for element in soup.find_all(tag):
element.decompose()
def create_scanbuild_code_links(soup, target_branch):
target = None
for element in soup.find_all("td"):
clz = element.get('class')
if clz is None:
src = element.text
target = element
elif 'Q' in clz and target is not None and target.text != 'Function/Method':
line = element.text
link = soup.new_tag('a', href=f'https://github.com/DataDog/java-profiler/blob/{target_branch}/ddprof-lib/src/main/cpp/{src}#L{line}')
link.string = src
target.clear()
target.append(link)
target = None
def parse_table(table):
markdown_table = []
for row in table.find_all('tr'):
cells = row.find_all(['th', 'td'])
markdown_cells = [cell.get_text(strip=True) for cell in cells]
markdown_table.append('| ' + ' | '.join(markdown_cells) + ' |')
return '\n'.join(markdown_table)
def scanbuild_cleanup(soup, args):
target_branch = args[0]
remove_tags(soup, ["title", "script", "a"])
create_scanbuild_code_links(soup, target_branch)
title = soup.find('h1')
title.string = 'Scan-Build Report'
return str(soup)
def cppcheck_cleanup(soup, args):
remove_tags(soup, ["title", "style", "head"])
return str(soup)
def usage(soup, args):
return "Usage"
if __name__ == "__main__":
actions = {
"scanbuild_cleanup": scanbuild_cleanup,
"cppcheck_cleanup": cppcheck_cleanup,
}
action = actions.get(sys.argv[1], usage)
input_file = sys.argv[2]
args = sys.argv[3:]
with open(input_file, "r") as file:
html_content = file.read()
soup = BeautifulSoup(html_content, "html.parser")
print(action(soup, args))
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.