Make scripts executable

This commit is contained in:
Paolo Tranquilli
2024-12-09 10:20:46 +01:00
parent 97ab31ab00
commit f74dcc7036
6 changed files with 12 additions and 8 deletions

2
misc/scripts/check-query-ids.py Normal file → Executable file
View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
from pathlib import Path from pathlib import Path
import re import re
import sys import sys

0
misc/scripts/create-change-note.py Normal file → Executable file
View File

4
misc/scripts/generate-code-scanning-query-list.py Normal file → Executable file
View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
import subprocess import subprocess
import json import json
import csv import csv
@@ -52,7 +54,7 @@ class CodeQL:
except: except:
self.proc.kill() self.proc.kill()
def command(self, args): def command(self, args):
data = json.dumps(args) data = json.dumps(args)
data_bytes = data.encode('utf-8') data_bytes = data.encode('utf-8')
self.proc.stdin.write(data_bytes) self.proc.stdin.write(data_bytes)

4
misc/scripts/models-as-data/generate_flow_model.py Normal file → Executable file
View File

@@ -140,7 +140,7 @@ Requirements: `codeql` should both appear on your path.
generator.setenvironment(sys.argv[1], sys.argv[2]) generator.setenvironment(sys.argv[1], sys.argv[2])
return generator return generator
def runQuery(self, query): def runQuery(self, query):
print("########## Querying " + query + "...") print("########## Querying " + query + "...")
@@ -224,7 +224,7 @@ extensions:
if self.dryRun: if self.dryRun:
print("Models as data extensions generated, but not written to file.") print("Models as data extensions generated, but not written to file.")
sys.exit(0) sys.exit(0)
if (self.generateSinks or if (self.generateSinks or
self.generateSources or self.generateSources or
self.generateSummaries or self.generateSummaries or

0
misc/scripts/pre-commit Normal file → Executable file
View File

10
misc/scripts/shared-code-metrics.py Normal file → Executable file
View File

@@ -1,7 +1,7 @@
#!/bin/env python3 #!/bin/env python3
# Generates a report on the amount of code sharing in this repo # Generates a report on the amount of code sharing in this repo
# #
# The purpose of this is # The purpose of this is
# a) To be able to understand the structure and dependencies # a) To be able to understand the structure and dependencies
# b) To provide a metric that measures the amount of shared vs non-shared code # b) To provide a metric that measures the amount of shared vs non-shared code
@@ -224,7 +224,7 @@ for qlfile in ql_file_index.values():
if lang in language_info: if lang in language_info:
info = language_info[lang] info = language_info[lang]
if qlfile.isOnlyInLanguage(lang): if qlfile.isOnlyInLanguage(lang):
info.addQlFile(qlfile) info.addQlFile(qlfile)
# Determine all package dependencies # Determine all package dependencies
@@ -276,15 +276,15 @@ def print_package_dependencies(packages):
nlines = package.lines + package.total_imported_lines nlines = package.lines + package.total_imported_lines
shared_percentage = 100 * package.total_imported_lines / nlines if nlines>0 else 0 shared_percentage = 100 * package.total_imported_lines / nlines if nlines>0 else 0
print('|', package.link(), '|', package.files, '|', package.lines, '|', package.total_imported_files, '|', package.total_imported_lines, '|', print('|', package.link(), '|', package.files, '|', package.lines, '|', package.total_imported_files, '|', package.total_imported_lines, '|',
# ','.join([p.name for p in package.all_dependencies]), # ','.join([p.name for p in package.all_dependencies]),
"%.2f" % shared_percentage, '|') "%.2f" % shared_percentage, '|')
print() print()
def print_language_dependencies(packages): def print_language_dependencies(packages):
print_package_dependencies([p for p in packages if p.name.endswith('-all') and p.name.count('-')==1]) print_package_dependencies([p for p in packages if p.name.endswith('-all') and p.name.count('-')==1])
def list_shared_code_by_language(language_info): def list_shared_code_by_language(language_info):
# For each language directory, list the files that are (1) inside the directory and not shared, # For each language directory, list the files that are (1) inside the directory and not shared,
# (2) packages from outside the directory, plus identical files # (2) packages from outside the directory, plus identical files
print('| Language | Non-shared files | Non-shared lines of code | Imported files | Imported lines of code | Shared code % |') print('| Language | Non-shared files | Non-shared lines of code | Imported files | Imported lines of code | Shared code % |')
print('| -------- | ---------------- | ------------------------ | -------------- | ---------------------- | ------------- |') print('| -------- | ---------------- | ------------------------ | -------------- | ---------------------- | ------------- |')