FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
codeql/misc/scripts/check-qhelp.py at codeql-cli/v2.27.1 · github/codeql · GitHub
github
codeql
Repository navigation
Code
Issues
1k
(1k)
Pull requests
474
(474)
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
codeql
/
misc
/
scripts
/
check-qhelp.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
75 lines (53 loc) · 1.75 KB
Breadcrumbs
codeql
/
misc
/
scripts
/
check-qhelp.py
Copy path
File metadata and controls
executable file
·
75 lines (53 loc) · 1.75 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/env python3
"""cross platform wrapper around codeql generate query-help to check .qhelp files
This takes care of:
* providing a temporary directory to --output
* finding usages of .inc.qhelp arguments
"""
import
pathlib
import
subprocess
import
sys
import
tempfile
import
xml
.
sax
include_cache
=
{}
class
IncludeHandler
(
xml
.
sax
.
ContentHandler
):
def
__init__
(
self
,
xml
):
super
().
__init__
()
self
.
__xml
=
xml
def
startElement
(
self
,
name
,
attrs
):
if
name
==
"include"
:
src
=
(
self
.
__xml
.
parent
/
attrs
[
"src"
]).
resolve
()
include_cache
.
setdefault
(
src
,
set
()).
add
(
self
.
__xml
)
class
IgnoreErrorsHandler
(
xml
.
sax
.
ErrorHandler
):
def
error
(
self
,
exc
):
pass
def
fatalError
(
self
,
exc
):
pass
def
warning
(
self
,
exc
):
pass
def
init_include_cache
():
if
not
include_cache
:
for
qhelp
in
pathlib
.
Path
().
rglob
(
"*.qhelp"
):
xml
.
sax
.
parse
(
qhelp
,
IncludeHandler
(
qhelp
),
IgnoreErrorsHandler
())
def
find_inc_qhelp_usages
(
arg
):
init_include_cache
()
return
include_cache
.
get
(
arg
.
resolve
(), ())
def
transform_inputs
(
args
):
for
arg
in
args
:
arg
=
pathlib
.
Path
(
arg
)
if
arg
.
suffixes
==
[
'.inc'
,
'.qhelp'
]:
for
qhelp
in
find_inc_qhelp_usages
(
arg
):
yield
str
(
qhelp
)
else
:
yield
str
(
arg
)
affected_qhelp_files
=
list
(
transform_inputs
(
sys
.
argv
[
1
:]))
if
not
affected_qhelp_files
:
# can happen with changes on an unused .inc.qhelp file
print
(
"nothing to do!"
)
sys
.
exit
(
0
)
cmd
=
[
"codeql"
,
"generate"
,
"query-help"
,
"--format=markdown"
]
with
tempfile
.
TemporaryDirectory
()
as
tmp
:
cmd
+=
[
f"--output=
{
tmp
}
"
,
"--"
]
cmd
+=
affected_qhelp_files
res
=
subprocess
.
run
(
cmd
)
sys
.
exit
(
res
.
returncode
)
Back
|
FazBrowse Home
|
New Git URL