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 — codeql/python/extractor/make_zips.py at codeql-cli/v2.26.2 · github/codeql

Expand file tree

/

make_zips.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
executable file
·
111 lines (89 loc) · 3.42 KB
/

make_zips.py

Copy path

File metadata and controls

executable file
·
111 lines (89 loc) · 3.42 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/env python
import os
import shutil
import sys
import zipfile
import optparse
import compileall
from python_tracer import getzipfilename
# TO DO -- Add options to set destination directory and source directory
def find_tools():
try:
return os.environ['PYTHON_INSTALLER_OUTPUT']
except KeyError:
pass
try:
return os.environ['ODASA_TOOLS']
except KeyError:
pass
try:
return os.path.join(os.environ['SEMMLE_DIST'], 'tools')
except KeyError:
pass
try:
return os.path.join(os.environ['ODASA_HOME'], 'tools')
except KeyError:
pass
raise Exception('ODASA_TOOLS environment variable is not set')
def find_src():
if __name__ == '__main__':
return os.path.dirname(os.path.abspath(sys.argv[0]))
raise Exception('Cannot find source code')
def build_byte_compiled_zip(src_dir, zippath):
# TODO(low): Why are we compiling ourselves, when writepy can also do that?
compileall.compile_dir(os.path.join(src_dir, 'semmle'), force=True, quiet=True)
zipped = zipfile.PyZipFile(zippath, 'w')
zipped.writepy(os.path.join(src_dir, '__main__.py'))
zipped.writepy(os.path.join(src_dir, 'semmle'))
zipped.writepy(os.path.join(src_dir, 'blib2to3'))
zipped.writepy(os.path.join(src_dir, 'lark'))
zipped.writepy(os.path.join(src_dir, 'buildtools'))
zipped.write(os.path.join(src_dir, 'blib2to3', 'Grammar.txt'), 'blib2to3/Grammar.txt')
zipped.write(os.path.join(src_dir, 'lark', 'grammars', 'common.lark'), 'lark/grammars/common.lark')
data_dir = os.path.join(src_dir, 'semmle', 'data')
for f in os.listdir(data_dir):
if f.endswith('.trap'):
zipped.write(os.path.join(data_dir, f), os.path.join('semmle', 'data', f))
zipped.close()
def build_source_zip(src_dir, zippath):
zipped = zipfile.PyZipFile(zippath, 'w')
zipped.write(os.path.join(src_dir, '__main__.py'), '__main__.py')
zipped.write(os.path.join(src_dir, 'imp.py'), 'imp.py')
write_source(zipped, src_dir, 'semmle')
write_source(zipped, src_dir, 'blib2to3', ('.py', '.txt', ''))
write_source(zipped, src_dir, 'lark', (".py", ".lark", ""))
write_source(zipped, src_dir, 'buildtools')
data_dir = os.path.join(src_dir, 'semmle', 'data')
for f in os.listdir(data_dir):
if f.endswith('.trap'):
zipped.write(os.path.join(data_dir, f), os.path.join('semmle', 'data', f))
zipped.close()
def write_source(zipped, root, name, extensions=[".py"]):
src = os.path.join(root, name)
for dirpath, _, filenames in os.walk(src):
for name in filenames:
_, ext = os.path.splitext(name)
if ext not in extensions:
continue
path = os.path.join(dirpath, name)
zipped.write(path, os.path.relpath(path, root))
def main():
parser = optparse.OptionParser(usage = "usage: %prog [install-dir]")
_, args = parser.parse_args(sys.argv[1:])
if len(args) > 1:
parser.print_usage()
elif args:
tools_dir = args[0]
if not os.path.exists(tools_dir):
os.makedirs(tools_dir)
else:
tools_dir = find_tools()
src_dir = find_src()
zippath = os.path.join(src_dir, getzipfilename())
if sys.version_info > (3,):
build_source_zip(src_dir, zippath)
else:
build_byte_compiled_zip(src_dir, zippath)
shutil.copy(zippath, tools_dir)
if __name__ == '__main__':
main()
You are visitor 01402520 — 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.