ci/lint: ensure double quotes are used in python
This commit is contained in:
1 parent
e5a383a525
commit
8a82882d5e
11 files changed
+288
-288
No files matched your search
@@ -27,17 +27,17 @@ import sys
|
||||
|
||||
|
||||
def convert_depfile(output, depfile):
|
||||
with open(depfile, 'r') as f:
|
||||
with open(depfile, "r") as f:
|
||||
deps = f.readlines()
|
||||
|
||||
with open(depfile, 'w') as f:
|
||||
with open(depfile, "w") as f:
|
||||
f.write(os.path.abspath(output))
|
||||
f.write(': \\\n')
|
||||
f.write(": \\\n")
|
||||
for dep in deps:
|
||||
dep = dep[:-1]
|
||||
f.write('\t')
|
||||
f.write("\t")
|
||||
f.write(os.path.abspath(dep))
|
||||
f.write(' \\\n')
|
||||
f.write(" \\\n")
|
||||
|
||||
def remove(path):
|
||||
try:
|
||||
@@ -51,7 +51,7 @@ depfile = None
|
||||
output = argv[-1]
|
||||
|
||||
for opt, optarg in zip(argv, argv[1:]):
|
||||
if opt == '--record-dependencies':
|
||||
if opt == "--record-dependencies":
|
||||
depfile = optarg
|
||||
|
||||
try:
|
||||
|
||||
+19
-19
@@ -20,7 +20,7 @@ def is_user_lib(objfile, libname):
|
||||
"libSystem." not in libname and \
|
||||
"libc." not in libname and \
|
||||
"libgcc." not in libname and \
|
||||
not os.path.basename(libname) == 'Python' and \
|
||||
not os.path.basename(libname) == "Python" and \
|
||||
os.path.basename(objfile) not in libname and \
|
||||
"libswift" not in libname
|
||||
|
||||
@@ -52,8 +52,8 @@ def get_rapths(objfile):
|
||||
for line in result.splitlines():
|
||||
line_clean = pathRe.search(line).group(1).strip()
|
||||
# resolve @loader_path
|
||||
if line_clean.startswith('@loader_path/'):
|
||||
line_clean = line_clean[len('@loader_path/'):]
|
||||
if line_clean.startswith("@loader_path/"):
|
||||
line_clean = line_clean[len("@loader_path/"):]
|
||||
line_clean = os.path.join(os.path.dirname(objfile), line_clean)
|
||||
line_clean = os.path.normpath(line_clean)
|
||||
rpaths.append(line_clean)
|
||||
@@ -63,7 +63,7 @@ def get_rapths(objfile):
|
||||
def get_rpaths_dev_tools(binary):
|
||||
command = (
|
||||
f"otool -l '{binary}' | grep -A2 LC_RPATH | grep path | "
|
||||
"grep \"Xcode\\|CommandLineTools\""
|
||||
'grep "Xcode\\|CommandLineTools"'
|
||||
)
|
||||
result = subprocess.check_output(command, shell = True, universal_newlines=True)
|
||||
pathRe = re.compile(r"^\s*path (.*) \(offset \d*\)$")
|
||||
@@ -78,19 +78,19 @@ def resolve_lib_path(objfile, lib, rapths):
|
||||
if os.path.exists(lib):
|
||||
return lib
|
||||
|
||||
if lib.startswith('@rpath/'):
|
||||
lib = lib[len('@rpath/'):]
|
||||
if lib.startswith("@rpath/"):
|
||||
lib = lib[len("@rpath/"):]
|
||||
for rpath in rapths:
|
||||
lib_path = os.path.join(rpath, lib)
|
||||
if os.path.exists(lib_path):
|
||||
return lib_path
|
||||
elif lib.startswith('@loader_path/'):
|
||||
lib = lib[len('@loader_path/'):]
|
||||
elif lib.startswith("@loader_path/"):
|
||||
lib = lib[len("@loader_path/"):]
|
||||
lib_path = os.path.normpath(os.path.join(objfile, lib))
|
||||
if os.path.exists(lib_path):
|
||||
return lib_path
|
||||
|
||||
raise Exception('Could not resolve library: ' + lib)
|
||||
raise Exception("Could not resolve library: " + lib)
|
||||
|
||||
def check_vulkan_max_version(version):
|
||||
try:
|
||||
@@ -149,10 +149,10 @@ def libraries(objfile, result = dict(), result_relative = set(), rapths = []):
|
||||
return result, result_relative
|
||||
|
||||
def lib_path(binary):
|
||||
return os.path.join(os.path.dirname(binary), 'lib')
|
||||
return os.path.join(os.path.dirname(binary), "lib")
|
||||
|
||||
def resources_path(binary):
|
||||
return os.path.join(os.path.dirname(binary), '../Resources')
|
||||
return os.path.join(os.path.dirname(binary), "../Resources")
|
||||
|
||||
def lib_name(lib):
|
||||
return os.path.join("@executable_path", "lib", os.path.basename(lib))
|
||||
@@ -185,20 +185,20 @@ def process_libraries(libs_dict, libs_dyn, binary):
|
||||
install_name_tool_change(lib, lib_name(lib), binary)
|
||||
|
||||
def process_swift_libraries(binary):
|
||||
command = ['xcrun', '--find', 'swift-stdlib-tool']
|
||||
command = ["xcrun", "--find", "swift-stdlib-tool"]
|
||||
swiftStdlibTool = subprocess.check_output(command, universal_newlines=True).strip()
|
||||
# from xcode11 on the dynamic swift libs reside in a separate directory from
|
||||
# the std one, might need versioned paths for future swift versions
|
||||
swiftLibPath = os.path.join(swiftStdlibTool, '../../lib/swift-5.0/macosx')
|
||||
swiftLibPath = os.path.join(swiftStdlibTool, "../../lib/swift-5.0/macosx")
|
||||
swiftLibPath = os.path.abspath(swiftLibPath)
|
||||
|
||||
command = [
|
||||
swiftStdlibTool, '--copy', '--platform', 'macosx', '--scan-executable',
|
||||
binary, '--destination', lib_path(binary)
|
||||
swiftStdlibTool, "--copy", "--platform", "macosx", "--scan-executable",
|
||||
binary, "--destination", lib_path(binary)
|
||||
]
|
||||
|
||||
if os.path.exists(swiftLibPath):
|
||||
command.extend(['--source-libraries', swiftLibPath])
|
||||
command.extend(["--source-libraries", swiftLibPath])
|
||||
|
||||
subprocess.check_output(command, universal_newlines=True)
|
||||
|
||||
@@ -216,7 +216,7 @@ def process_vulkan_loader(binary, loaderName, loaderRelativeFolder, libraryNode)
|
||||
os.path.join(os.path.expanduser("~"), ".local/share", loaderRelativeFolder),
|
||||
os.path.join("/usr/local/share", loaderRelativeFolder),
|
||||
os.path.join("/usr/share/vulkan", loaderRelativeFolder),
|
||||
os.path.join(get_homebrew_prefix(), 'share', loaderRelativeFolder),
|
||||
os.path.join(get_homebrew_prefix(), "share", loaderRelativeFolder),
|
||||
]
|
||||
|
||||
loaderSystemFolder = ""
|
||||
@@ -241,7 +241,7 @@ def process_vulkan_loader(binary, loaderName, loaderRelativeFolder, libraryNode)
|
||||
if not os.path.exists(loaderBundleFolder):
|
||||
os.makedirs(loaderBundleFolder)
|
||||
|
||||
loaderSystemFile = open(loaderSystemPath, 'r')
|
||||
loaderSystemFile = open(loaderSystemPath, "r")
|
||||
loaderJsonData = json.load(loaderSystemFile)
|
||||
libraryPath = loaderJsonData[libraryNode]["library_path"]
|
||||
librarySystemPath = os.path.join(loaderSystemFolder, libraryPath)
|
||||
@@ -251,7 +251,7 @@ def process_vulkan_loader(binary, loaderName, loaderRelativeFolder, libraryNode)
|
||||
return
|
||||
|
||||
print(">>> modifiying and writing loader json " + loaderName)
|
||||
loaderBundleFile = open(loaderBundlePath, 'w')
|
||||
loaderBundleFile = open(loaderBundlePath, "w")
|
||||
loaderLibraryName = os.path.basename(librarySystemPath)
|
||||
library_path = os.path.join(libraryRelativeFolder, loaderLibraryName)
|
||||
loaderJsonData[libraryNode]["library_path"] = library_path
|
||||
|
||||
@@ -35,11 +35,10 @@ def file2string(infilename, infile, outfile):
|
||||
for c in safe_chars:
|
||||
conv[ord(c)] = c
|
||||
for c, esc in ("\nn", "\tt", r"\\", '""'):
|
||||
conv[ord(c)] = '\\' + esc
|
||||
conv[ord(c)] = "\\" + esc
|
||||
for line in infile:
|
||||
outfile.write('"' + ''.join(conv[c] for c in line) + '"\n')
|
||||
outfile.write('"' + "".join(conv[c] for c in line) + '"\n')
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
with open(sys.argv[1], 'rb') as infile, open(sys.argv[2], "w") as outfile:
|
||||
with open(sys.argv[1], "rb") as infile, open(sys.argv[2], "w") as outfile:
|
||||
file2string(os.path.relpath(sys.argv[1], sys.argv[3]), infile, outfile)
|
||||
@@ -53,7 +53,7 @@ if __name__ == "__main__":
|
||||
print(f"Usage: {sys.argv[0]} <version>")
|
||||
sys.exit(1)
|
||||
|
||||
git = which('git')
|
||||
git = which("git")
|
||||
if not git:
|
||||
print("Unable to find git binary")
|
||||
sys.exit(1)
|
||||
|
||||
+10
-10
@@ -10,27 +10,27 @@ from shutil import which
|
||||
from subprocess import check_output
|
||||
|
||||
def find_macos_sdk():
|
||||
sdk = os.environ.get('MACOS_SDK', '')
|
||||
sdk_version = os.environ.get('MACOS_SDK_VERSION', '0.0')
|
||||
xcrun = which('xcrun')
|
||||
xcodebuild = which('xcodebuild')
|
||||
sdk = os.environ.get("MACOS_SDK", "")
|
||||
sdk_version = os.environ.get("MACOS_SDK_VERSION", "0.0")
|
||||
xcrun = which("xcrun")
|
||||
xcodebuild = which("xcodebuild")
|
||||
|
||||
if not xcrun:
|
||||
return sdk,sdk_version
|
||||
|
||||
if not sdk:
|
||||
sdk = check_output([xcrun, '--sdk', 'macosx', '--show-sdk-path'],
|
||||
sdk = check_output([xcrun, "--sdk", "macosx", "--show-sdk-path"],
|
||||
encoding="UTF-8")
|
||||
|
||||
# find macOS SDK paths and version
|
||||
if sdk_version == '0.0':
|
||||
sdk_version = check_output([xcrun, '--sdk', 'macosx', '--show-sdk-version'],
|
||||
if sdk_version == "0.0":
|
||||
sdk_version = check_output([xcrun, "--sdk", "macosx", "--show-sdk-version"],
|
||||
encoding="UTF-8")
|
||||
|
||||
# use xcode tools when installed, still necessary for xcode versions <12.0
|
||||
try:
|
||||
sdk_version = check_output(
|
||||
[xcodebuild, '-sdk', 'macosx', '-version', 'ProductVersion'],
|
||||
[xcodebuild, "-sdk", "macosx", "-version", "ProductVersion"],
|
||||
encoding="UTF-8",
|
||||
stderr=subprocess.DEVNULL
|
||||
)
|
||||
@@ -38,10 +38,10 @@ def find_macos_sdk():
|
||||
pass
|
||||
|
||||
if not isinstance(sdk_version, str):
|
||||
sdk_version = '10.10.0'
|
||||
sdk_version = "10.10.0"
|
||||
|
||||
return sdk.strip(),sdk_version.strip()
|
||||
|
||||
if __name__ == "__main__":
|
||||
sdk_info = find_macos_sdk()
|
||||
sys.stdout.write(','.join(sdk_info))
|
||||
sys.stdout.write(",".join(sdk_info))
|
||||
@@ -9,7 +9,7 @@ from shutil import which
|
||||
from subprocess import check_output
|
||||
|
||||
def find_swift_lib():
|
||||
swift_lib_dir = os.environ.get('SWIFT_LIB_DYNAMIC', '')
|
||||
swift_lib_dir = os.environ.get("SWIFT_LIB_DYNAMIC", "")
|
||||
if swift_lib_dir:
|
||||
return swift_lib_dir
|
||||
|
||||
|
||||
+230
-230
@@ -27,218 +27,218 @@ from binascii import hexlify
|
||||
|
||||
|
||||
elements_ebml = (
|
||||
'EBML, 1a45dfa3, sub', (
|
||||
'EBMLVersion, 4286, uint',
|
||||
'EBMLReadVersion, 42f7, uint',
|
||||
'EBMLMaxIDLength, 42f2, uint',
|
||||
'EBMLMaxSizeLength, 42f3, uint',
|
||||
'DocType, 4282, str',
|
||||
'DocTypeVersion, 4287, uint',
|
||||
'DocTypeReadVersion, 4285, uint',
|
||||
"EBML, 1a45dfa3, sub", (
|
||||
"EBMLVersion, 4286, uint",
|
||||
"EBMLReadVersion, 42f7, uint",
|
||||
"EBMLMaxIDLength, 42f2, uint",
|
||||
"EBMLMaxSizeLength, 42f3, uint",
|
||||
"DocType, 4282, str",
|
||||
"DocTypeVersion, 4287, uint",
|
||||
"DocTypeReadVersion, 4285, uint",
|
||||
),
|
||||
|
||||
'CRC32, bf, binary',
|
||||
'Void, ec, binary',
|
||||
"CRC32, bf, binary",
|
||||
"Void, ec, binary",
|
||||
)
|
||||
|
||||
elements_matroska = (
|
||||
'Segment, 18538067, sub', (
|
||||
"Segment, 18538067, sub", (
|
||||
|
||||
'SeekHead*, 114d9b74, sub', (
|
||||
'Seek*, 4dbb, sub', (
|
||||
'SeekID, 53ab, ebml_id',
|
||||
'SeekPosition, 53ac, uint',
|
||||
"SeekHead*, 114d9b74, sub", (
|
||||
"Seek*, 4dbb, sub", (
|
||||
"SeekID, 53ab, ebml_id",
|
||||
"SeekPosition, 53ac, uint",
|
||||
),
|
||||
),
|
||||
|
||||
'Info*, 1549a966, sub', (
|
||||
'SegmentUID, 73a4, binary',
|
||||
'PrevUID, 3cb923, binary',
|
||||
'NextUID, 3eb923, binary',
|
||||
'TimecodeScale, 2ad7b1, uint',
|
||||
'DateUTC, 4461, sint',
|
||||
'Title, 7ba9, str',
|
||||
'MuxingApp, 4d80, str',
|
||||
'WritingApp, 5741, str',
|
||||
'Duration, 4489, float',
|
||||
"Info*, 1549a966, sub", (
|
||||
"SegmentUID, 73a4, binary",
|
||||
"PrevUID, 3cb923, binary",
|
||||
"NextUID, 3eb923, binary",
|
||||
"TimecodeScale, 2ad7b1, uint",
|
||||
"DateUTC, 4461, sint",
|
||||
"Title, 7ba9, str",
|
||||
"MuxingApp, 4d80, str",
|
||||
"WritingApp, 5741, str",
|
||||
"Duration, 4489, float",
|
||||
),
|
||||
|
||||
'Cluster*, 1f43b675, sub', (
|
||||
'Timecode, e7, uint',
|
||||
'BlockGroup*, a0, sub', (
|
||||
'Block, a1, binary',
|
||||
'BlockDuration, 9b, uint',
|
||||
'ReferenceBlock*, fb, sint',
|
||||
'DiscardPadding, 75A2, sint',
|
||||
'BlockAdditions, 75A1, sub', (
|
||||
'BlockMore*, A6, sub', (
|
||||
'BlockAddID, EE, uint',
|
||||
'BlockAdditional, A5, binary',
|
||||
"Cluster*, 1f43b675, sub", (
|
||||
"Timecode, e7, uint",
|
||||
"BlockGroup*, a0, sub", (
|
||||
"Block, a1, binary",
|
||||
"BlockDuration, 9b, uint",
|
||||
"ReferenceBlock*, fb, sint",
|
||||
"DiscardPadding, 75A2, sint",
|
||||
"BlockAdditions, 75A1, sub", (
|
||||
"BlockMore*, A6, sub", (
|
||||
"BlockAddID, EE, uint",
|
||||
"BlockAdditional, A5, binary",
|
||||
),
|
||||
),
|
||||
),
|
||||
'SimpleBlock*, a3, binary',
|
||||
"SimpleBlock*, a3, binary",
|
||||
),
|
||||
|
||||
'Tracks*, 1654ae6b, sub', (
|
||||
'TrackEntry*, ae, sub', (
|
||||
'TrackNumber, d7, uint',
|
||||
'TrackUID, 73c5, uint',
|
||||
'TrackType, 83, uint',
|
||||
'FlagEnabled, b9, uint',
|
||||
'FlagDefault, 88, uint',
|
||||
'FlagForced, 55aa, uint',
|
||||
'FlagLacing, 9c, uint',
|
||||
'MinCache, 6de7, uint',
|
||||
'MaxCache, 6df8, uint',
|
||||
'DefaultDuration, 23e383, uint',
|
||||
'TrackTimecodeScale, 23314f, float',
|
||||
'MaxBlockAdditionID, 55ee, uint',
|
||||
'Name, 536e, str',
|
||||
'Language, 22b59c, str',
|
||||
'LanguageBCP47, 22b59d, str',
|
||||
'CodecID, 86, str',
|
||||
'CodecPrivate, 63a2, binary',
|
||||
'CodecName, 258688, str',
|
||||
'CodecDecodeAll, aa, uint',
|
||||
'CodecDelay, 56aa, uint',
|
||||
'SeekPreRoll, 56bb, uint',
|
||||
'Video, e0, sub', (
|
||||
'FlagInterlaced, 9a, uint',
|
||||
'PixelWidth, b0, uint',
|
||||
'PixelHeight, ba, uint',
|
||||
'DisplayWidth, 54b0, uint',
|
||||
'DisplayHeight, 54ba, uint',
|
||||
'DisplayUnit, 54b2, uint',
|
||||
'PixelCropTop, 54bb, uint',
|
||||
'PixelCropLeft, 54cc, uint',
|
||||
'PixelCropRight, 54dd, uint',
|
||||
'PixelCropBottom, 54aa, uint',
|
||||
'FrameRate, 2383e3, float',
|
||||
'ColourSpace, 2eb524, binary',
|
||||
'StereoMode, 53b8, uint',
|
||||
'Colour, 55b0, sub', (
|
||||
'MatrixCoefficients, 55B1, uint',
|
||||
'BitsPerChannel, 55B2, uint',
|
||||
'ChromaSubsamplingHorz, 55B3, uint',
|
||||
'ChromaSubsamplingVert, 55B4, uint',
|
||||
'CbSubsamplingHorz, 55B5, uint',
|
||||
'CbSubsamplingVert, 55B6, uint',
|
||||
'ChromaSitingHorz, 55B7, uint',
|
||||
'ChromaSitingVert, 55B8, uint',
|
||||
'Range, 55B9, uint',
|
||||
'TransferCharacteristics, 55BA, uint',
|
||||
'Primaries, 55BB, uint',
|
||||
'MaxCLL, 55BC, uint',
|
||||
'MaxFALL, 55BD, uint',
|
||||
'MasteringMetadata, 55D0, sub', (
|
||||
'PrimaryRChromaticityX, 55D1, float',
|
||||
'PrimaryRChromaticityY, 55D2, float',
|
||||
'PrimaryGChromaticityX, 55D3, float',
|
||||
'PrimaryGChromaticityY, 55D4, float',
|
||||
'PrimaryBChromaticityX, 55D5, float',
|
||||
'PrimaryBChromaticityY, 55D6, float',
|
||||
'WhitePointChromaticityX, 55D7, float',
|
||||
'WhitePointChromaticityY, 55D8, float',
|
||||
'LuminanceMax, 55D9, float',
|
||||
'LuminanceMin, 55DA, float',
|
||||
"Tracks*, 1654ae6b, sub", (
|
||||
"TrackEntry*, ae, sub", (
|
||||
"TrackNumber, d7, uint",
|
||||
"TrackUID, 73c5, uint",
|
||||
"TrackType, 83, uint",
|
||||
"FlagEnabled, b9, uint",
|
||||
"FlagDefault, 88, uint",
|
||||
"FlagForced, 55aa, uint",
|
||||
"FlagLacing, 9c, uint",
|
||||
"MinCache, 6de7, uint",
|
||||
"MaxCache, 6df8, uint",
|
||||
"DefaultDuration, 23e383, uint",
|
||||
"TrackTimecodeScale, 23314f, float",
|
||||
"MaxBlockAdditionID, 55ee, uint",
|
||||
"Name, 536e, str",
|
||||
"Language, 22b59c, str",
|
||||
"LanguageBCP47, 22b59d, str",
|
||||
"CodecID, 86, str",
|
||||
"CodecPrivate, 63a2, binary",
|
||||
"CodecName, 258688, str",
|
||||
"CodecDecodeAll, aa, uint",
|
||||
"CodecDelay, 56aa, uint",
|
||||
"SeekPreRoll, 56bb, uint",
|
||||
"Video, e0, sub", (
|
||||
"FlagInterlaced, 9a, uint",
|
||||
"PixelWidth, b0, uint",
|
||||
"PixelHeight, ba, uint",
|
||||
"DisplayWidth, 54b0, uint",
|
||||
"DisplayHeight, 54ba, uint",
|
||||
"DisplayUnit, 54b2, uint",
|
||||
"PixelCropTop, 54bb, uint",
|
||||
"PixelCropLeft, 54cc, uint",
|
||||
"PixelCropRight, 54dd, uint",
|
||||
"PixelCropBottom, 54aa, uint",
|
||||
"FrameRate, 2383e3, float",
|
||||
"ColourSpace, 2eb524, binary",
|
||||
"StereoMode, 53b8, uint",
|
||||
"Colour, 55b0, sub", (
|
||||
"MatrixCoefficients, 55B1, uint",
|
||||
"BitsPerChannel, 55B2, uint",
|
||||
"ChromaSubsamplingHorz, 55B3, uint",
|
||||
"ChromaSubsamplingVert, 55B4, uint",
|
||||
"CbSubsamplingHorz, 55B5, uint",
|
||||
"CbSubsamplingVert, 55B6, uint",
|
||||
"ChromaSitingHorz, 55B7, uint",
|
||||
"ChromaSitingVert, 55B8, uint",
|
||||
"Range, 55B9, uint",
|
||||
"TransferCharacteristics, 55BA, uint",
|
||||
"Primaries, 55BB, uint",
|
||||
"MaxCLL, 55BC, uint",
|
||||
"MaxFALL, 55BD, uint",
|
||||
"MasteringMetadata, 55D0, sub", (
|
||||
"PrimaryRChromaticityX, 55D1, float",
|
||||
"PrimaryRChromaticityY, 55D2, float",
|
||||
"PrimaryGChromaticityX, 55D3, float",
|
||||
"PrimaryGChromaticityY, 55D4, float",
|
||||
"PrimaryBChromaticityX, 55D5, float",
|
||||
"PrimaryBChromaticityY, 55D6, float",
|
||||
"WhitePointChromaticityX, 55D7, float",
|
||||
"WhitePointChromaticityY, 55D8, float",
|
||||
"LuminanceMax, 55D9, float",
|
||||
"LuminanceMin, 55DA, float",
|
||||
),
|
||||
),
|
||||
'Projection, 7670, sub', (
|
||||
'ProjectionType, 7671, uint',
|
||||
'ProjectionPrivate, 7672, binary',
|
||||
'ProjectionPoseYaw, 7673, float',
|
||||
'ProjectionPosePitch, 7674, float',
|
||||
'ProjectionPoseRoll, 7675, float',
|
||||
"Projection, 7670, sub", (
|
||||
"ProjectionType, 7671, uint",
|
||||
"ProjectionPrivate, 7672, binary",
|
||||
"ProjectionPoseYaw, 7673, float",
|
||||
"ProjectionPosePitch, 7674, float",
|
||||
"ProjectionPoseRoll, 7675, float",
|
||||
),
|
||||
),
|
||||
'Audio, e1, sub', (
|
||||
'SamplingFrequency, b5, float',
|
||||
'OutputSamplingFrequency, 78b5, float',
|
||||
'Channels, 9f, uint',
|
||||
'BitDepth, 6264, uint',
|
||||
"Audio, e1, sub", (
|
||||
"SamplingFrequency, b5, float",
|
||||
"OutputSamplingFrequency, 78b5, float",
|
||||
"Channels, 9f, uint",
|
||||
"BitDepth, 6264, uint",
|
||||
),
|
||||
'ContentEncodings, 6d80, sub', (
|
||||
'ContentEncoding*, 6240, sub', (
|
||||
'ContentEncodingOrder, 5031, uint',
|
||||
'ContentEncodingScope, 5032, uint',
|
||||
'ContentEncodingType, 5033, uint',
|
||||
'ContentCompression, 5034, sub', (
|
||||
'ContentCompAlgo, 4254, uint',
|
||||
'ContentCompSettings, 4255, binary',
|
||||
"ContentEncodings, 6d80, sub", (
|
||||
"ContentEncoding*, 6240, sub", (
|
||||
"ContentEncodingOrder, 5031, uint",
|
||||
"ContentEncodingScope, 5032, uint",
|
||||
"ContentEncodingType, 5033, uint",
|
||||
"ContentCompression, 5034, sub", (
|
||||
"ContentCompAlgo, 4254, uint",
|
||||
"ContentCompSettings, 4255, binary",
|
||||
),
|
||||
),
|
||||
),
|
||||
'BlockAdditionMapping*, 41e4, sub', (
|
||||
'BlockAddIDValue, 41f0, uint',
|
||||
'BlockAddIDName, 41a4, str',
|
||||
'BlockAddIDType, 41e7, uint',
|
||||
'BlockAddIDExtraData, 41ed, binary',
|
||||
"BlockAdditionMapping*, 41e4, sub", (
|
||||
"BlockAddIDValue, 41f0, uint",
|
||||
"BlockAddIDName, 41a4, str",
|
||||
"BlockAddIDType, 41e7, uint",
|
||||
"BlockAddIDExtraData, 41ed, binary",
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
'Cues, 1c53bb6b, sub', (
|
||||
'CuePoint*, bb, sub', (
|
||||
'CueTime, b3, uint',
|
||||
'CueTrackPositions*, b7, sub', (
|
||||
'CueTrack, f7, uint',
|
||||
'CueClusterPosition, f1, uint',
|
||||
'CueRelativePosition, f0, uint',
|
||||
'CueDuration, b2, uint',
|
||||
"Cues, 1c53bb6b, sub", (
|
||||
"CuePoint*, bb, sub", (
|
||||
"CueTime, b3, uint",
|
||||
"CueTrackPositions*, b7, sub", (
|
||||
"CueTrack, f7, uint",
|
||||
"CueClusterPosition, f1, uint",
|
||||
"CueRelativePosition, f0, uint",
|
||||
"CueDuration, b2, uint",
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
'Attachments, 1941a469, sub', (
|
||||
'AttachedFile*, 61a7, sub', (
|
||||
'FileDescription, 467e, str',
|
||||
'FileName, 466e, str',
|
||||
'FileMimeType, 4660, str',
|
||||
'FileData, 465c, binary',
|
||||
'FileUID, 46ae, uint',
|
||||
"Attachments, 1941a469, sub", (
|
||||
"AttachedFile*, 61a7, sub", (
|
||||
"FileDescription, 467e, str",
|
||||
"FileName, 466e, str",
|
||||
"FileMimeType, 4660, str",
|
||||
"FileData, 465c, binary",
|
||||
"FileUID, 46ae, uint",
|
||||
),
|
||||
),
|
||||
|
||||
'Chapters, 1043a770, sub', (
|
||||
'EditionEntry*, 45b9, sub', (
|
||||
'EditionUID, 45bc, uint',
|
||||
'EditionFlagHidden, 45bd, uint',
|
||||
'EditionFlagDefault, 45db, uint',
|
||||
'EditionFlagOrdered, 45dd, uint',
|
||||
'ChapterAtom*, b6, sub', (
|
||||
'ChapterUID, 73c4, uint',
|
||||
'ChapterTimeStart, 91, uint',
|
||||
'ChapterTimeEnd, 92, uint',
|
||||
'ChapterFlagHidden, 98, uint',
|
||||
'ChapterFlagEnabled, 4598, uint',
|
||||
'ChapterSegmentUID, 6e67, binary',
|
||||
'ChapterSegmentEditionUID, 6ebc, uint',
|
||||
'ChapterDisplay*, 80, sub', (
|
||||
'ChapString, 85, str',
|
||||
'ChapLanguage*, 437c, str',
|
||||
'ChapLanguageBCP47*, 437d, str',
|
||||
'ChapCountry*, 437e, str',
|
||||
"Chapters, 1043a770, sub", (
|
||||
"EditionEntry*, 45b9, sub", (
|
||||
"EditionUID, 45bc, uint",
|
||||
"EditionFlagHidden, 45bd, uint",
|
||||
"EditionFlagDefault, 45db, uint",
|
||||
"EditionFlagOrdered, 45dd, uint",
|
||||
"ChapterAtom*, b6, sub", (
|
||||
"ChapterUID, 73c4, uint",
|
||||
"ChapterTimeStart, 91, uint",
|
||||
"ChapterTimeEnd, 92, uint",
|
||||
"ChapterFlagHidden, 98, uint",
|
||||
"ChapterFlagEnabled, 4598, uint",
|
||||
"ChapterSegmentUID, 6e67, binary",
|
||||
"ChapterSegmentEditionUID, 6ebc, uint",
|
||||
"ChapterDisplay*, 80, sub", (
|
||||
"ChapString, 85, str",
|
||||
"ChapLanguage*, 437c, str",
|
||||
"ChapLanguageBCP47*, 437d, str",
|
||||
"ChapCountry*, 437e, str",
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'Tags*, 1254c367, sub', (
|
||||
'Tag*, 7373, sub', (
|
||||
'Targets, 63c0, sub', (
|
||||
'TargetTypeValue, 68ca, uint',
|
||||
'TargetType, 63ca, str',
|
||||
'TargetTrackUID, 63c5, uint',
|
||||
'TargetEditionUID, 63c9, uint',
|
||||
'TargetChapterUID, 63c4, uint',
|
||||
'TargetAttachmentUID, 63c6, uint',
|
||||
"Tags*, 1254c367, sub", (
|
||||
"Tag*, 7373, sub", (
|
||||
"Targets, 63c0, sub", (
|
||||
"TargetTypeValue, 68ca, uint",
|
||||
"TargetType, 63ca, str",
|
||||
"TargetTrackUID, 63c5, uint",
|
||||
"TargetEditionUID, 63c9, uint",
|
||||
"TargetChapterUID, 63c4, uint",
|
||||
"TargetAttachmentUID, 63c6, uint",
|
||||
),
|
||||
'SimpleTag*, 67c8, sub', (
|
||||
'TagName, 45a3, str',
|
||||
'TagLanguage, 447a, str',
|
||||
'TagLanguageBCP47, 447b, str',
|
||||
'TagString, 4487, str',
|
||||
'TagDefault, 4484, uint',
|
||||
"SimpleTag*, 67c8, sub", (
|
||||
"TagName, 45a3, str",
|
||||
"TagLanguage, 447a, str",
|
||||
"TagLanguageBCP47, 447b, str",
|
||||
"TagString, 4487, str",
|
||||
"TagDefault, 4484, uint",
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -261,29 +261,29 @@ def camelcase_to_words(name):
|
||||
parts.append(name[start:i])
|
||||
start = i
|
||||
parts.append(name[start:])
|
||||
return '_'.join(parts).lower()
|
||||
return "_".join(parts).lower()
|
||||
|
||||
class MatroskaElement(object):
|
||||
|
||||
def __init__(self, name, elid, valtype, namespace):
|
||||
self.name = name
|
||||
self.definename = '{0}_ID_{1}'.format(namespace, name.upper())
|
||||
self.definename = "{0}_ID_{1}".format(namespace, name.upper())
|
||||
self.fieldname = camelcase_to_words(name)
|
||||
self.structname = 'ebml_' + self.fieldname
|
||||
self.structname = "ebml_" + self.fieldname
|
||||
self.elid = elid
|
||||
self.valtype = valtype
|
||||
if valtype == 'sub':
|
||||
self.ebmltype = 'EBML_TYPE_SUBELEMENTS'
|
||||
self.valname = 'struct ' + self.structname
|
||||
if valtype == "sub":
|
||||
self.ebmltype = "EBML_TYPE_SUBELEMENTS"
|
||||
self.valname = "struct " + self.structname
|
||||
else:
|
||||
self.ebmltype = 'EBML_TYPE_' + valtype.upper()
|
||||
self.ebmltype = "EBML_TYPE_" + valtype.upper()
|
||||
try:
|
||||
self.valname = {'uint': 'uint64_t', 'str': 'char *',
|
||||
'binary': 'bstr', 'ebml_id': 'uint32_t',
|
||||
'float': 'double', 'sint': 'int64_t',
|
||||
self.valname = {"uint": "uint64_t", "str": "char *",
|
||||
"binary": "bstr", "ebml_id": "uint32_t",
|
||||
"float": "double", "sint": "int64_t",
|
||||
}[valtype]
|
||||
except KeyError:
|
||||
raise SyntaxError('Unrecognized value type ' + valtype)
|
||||
raise SyntaxError("Unrecognized value type " + valtype)
|
||||
self.subelements = ()
|
||||
|
||||
def add_subelements(self, subelements):
|
||||
@@ -296,10 +296,10 @@ def parse_elems(elements, namespace):
|
||||
subelements = []
|
||||
for el in elements:
|
||||
if isinstance(el, str):
|
||||
name, hexid, eltype = [x.strip() for x in el.split(',')]
|
||||
name, hexid, eltype = [x.strip() for x in el.split(",")]
|
||||
hexid = hexid.lower()
|
||||
multiple = name.endswith('*')
|
||||
name = name.strip('*')
|
||||
multiple = name.endswith("*")
|
||||
name = name.strip("*")
|
||||
new = MatroskaElement(name, hexid, eltype, namespace)
|
||||
elementd[hexid] = new
|
||||
elementlist.append(new)
|
||||
@@ -308,19 +308,19 @@ def parse_elems(elements, namespace):
|
||||
new.add_subelements(parse_elems(el, namespace))
|
||||
return subelements
|
||||
|
||||
parse_elems(elements_ebml, 'EBML')
|
||||
parse_elems(elements_matroska, 'MATROSKA')
|
||||
parse_elems(elements_ebml, "EBML")
|
||||
parse_elems(elements_matroska, "MATROSKA")
|
||||
|
||||
def printf(out, *args):
|
||||
out.write(' '.join(str(x) for x in args))
|
||||
out.write('\n')
|
||||
out.write(" ".join(str(x) for x in args))
|
||||
out.write("\n")
|
||||
|
||||
def generate_C_header(out):
|
||||
printf(out, '// Generated by TOOLS/matroska.py, do not edit manually')
|
||||
printf(out, "// Generated by TOOLS/matroska.py, do not edit manually")
|
||||
printf(out)
|
||||
|
||||
for el in elementlist:
|
||||
printf(out, '#define {0.definename:40} 0x{0.elid}'.format(el))
|
||||
printf(out, "#define {0.definename:40} 0x{0.elid}".format(el))
|
||||
|
||||
printf(out)
|
||||
|
||||
@@ -328,39 +328,39 @@ def generate_C_header(out):
|
||||
if not el.subelements:
|
||||
continue
|
||||
printf(out)
|
||||
printf(out, 'struct {0.structname} {{'.format(el))
|
||||
printf(out, "struct {0.structname} {{".format(el))
|
||||
length = max(len(subel.valname) for subel, multiple in el.subelements)+1
|
||||
for subel, multiple in el.subelements:
|
||||
printf(out, ' {e.valname:{length}} {star}{e.fieldname};'.format(
|
||||
e=subel, length=length, star=' *'[multiple]))
|
||||
printf(out, " {e.valname:{length}} {star}{e.fieldname};".format(
|
||||
e=subel, length=length, star=" *"[multiple]))
|
||||
printf(out)
|
||||
for subel, multiple in el.subelements:
|
||||
printf(out, ' int n_{0.fieldname};'.format(subel))
|
||||
printf(out, '};')
|
||||
printf(out, " int n_{0.fieldname};".format(subel))
|
||||
printf(out, "};")
|
||||
|
||||
for el in elementlist:
|
||||
if not el.subelements:
|
||||
continue
|
||||
printf(out, f'extern const struct ebml_elem_desc {el.structname}_desc;')
|
||||
printf(out, f"extern const struct ebml_elem_desc {el.structname}_desc;")
|
||||
|
||||
printf(out)
|
||||
printf(out, '#define MAX_EBML_SUBELEMENTS', max(len(el.subelements)
|
||||
printf(out, "#define MAX_EBML_SUBELEMENTS", max(len(el.subelements)
|
||||
for el in elementlist))
|
||||
|
||||
|
||||
def generate_C_definitions(out):
|
||||
printf(out, '// Generated by TOOLS/matroska.py, do not edit manually')
|
||||
printf(out, "// Generated by TOOLS/matroska.py, do not edit manually")
|
||||
printf(out)
|
||||
for el in reversed(elementlist):
|
||||
printf(out)
|
||||
if el.subelements:
|
||||
printf(out, '#define N', el.fieldname)
|
||||
printf(out, "#define N", el.fieldname)
|
||||
printf(out, 'E_S("{0}", {1})'.format(el.name, len(el.subelements)))
|
||||
for subel, multiple in el.subelements:
|
||||
printf(out, 'F({0.definename}, {0.fieldname}, {1})'.format(
|
||||
printf(out, "F({0.definename}, {0.fieldname}, {1})".format(
|
||||
subel, int(multiple)))
|
||||
printf(out, '}};')
|
||||
printf(out, '#undef N')
|
||||
printf(out, "}};")
|
||||
printf(out, "#undef N")
|
||||
else:
|
||||
printf(out, 'E("{0.name}", {0.fieldname}, {0.ebmltype})'.format(el))
|
||||
|
||||
@@ -425,48 +425,48 @@ def read_float(s, length):
|
||||
return f
|
||||
|
||||
def parse_one(s, depth, parent, maxlen):
|
||||
elid = hexlify(read_id(s)).decode('ascii')
|
||||
elid = hexlify(read_id(s)).decode("ascii")
|
||||
elem = elementd.get(elid)
|
||||
size, length = read_vint(s)
|
||||
this_length = len(elid) / 2 + size + length
|
||||
if elem is not None:
|
||||
if elem.valtype != 'skip':
|
||||
if elem.valtype != "skip":
|
||||
indent = " " * depth
|
||||
print(f"{indent} [{elid}] {elem.name} size: {length} value:", end=' ')
|
||||
if elem.valtype == 'sub':
|
||||
print('subelements:')
|
||||
print(f"{indent} [{elid}] {elem.name} size: {length} value:", end=" ")
|
||||
if elem.valtype == "sub":
|
||||
print("subelements:")
|
||||
while length > 0:
|
||||
length -= parse_one(s, depth + 1, elem, length)
|
||||
if length < 0:
|
||||
raise SyntaxError
|
||||
elif elem.valtype == 'str':
|
||||
print('string', repr(read_str(s, length).decode('utf8', 'replace')))
|
||||
elif elem.valtype in ('binary', 'ebml_id'):
|
||||
elif elem.valtype == "str":
|
||||
print("string", repr(read_str(s, length).decode("utf8", "replace")))
|
||||
elif elem.valtype in ("binary", "ebml_id"):
|
||||
t = read_str(s, length)
|
||||
dec = ''
|
||||
if elem.valtype == 'ebml_id':
|
||||
idelem = elementd.get(hexlify(t).decode('ascii'))
|
||||
dec = ""
|
||||
if elem.valtype == "ebml_id":
|
||||
idelem = elementd.get(hexlify(t).decode("ascii"))
|
||||
if idelem is None:
|
||||
dec = '(UNKNOWN)'
|
||||
dec = "(UNKNOWN)"
|
||||
else:
|
||||
dec = '({0.name})'.format(idelem)
|
||||
dec = "({0.name})".format(idelem)
|
||||
if len(t) < 20:
|
||||
t = hexlify(t).decode('ascii')
|
||||
t = hexlify(t).decode("ascii")
|
||||
else:
|
||||
t = '<{0} bytes>'.format(len(t))
|
||||
print('binary', t, dec)
|
||||
elif elem.valtype == 'uint':
|
||||
print('uint', read_uint(s, length))
|
||||
elif elem.valtype == 'sint':
|
||||
print('sint', read_sint(s, length))
|
||||
elif elem.valtype == 'float':
|
||||
print('float', read_float(s, length))
|
||||
elif elem.valtype == 'skip':
|
||||
t = "<{0} bytes>".format(len(t))
|
||||
print("binary", t, dec)
|
||||
elif elem.valtype == "uint":
|
||||
print("uint", read_uint(s, length))
|
||||
elif elem.valtype == "sint":
|
||||
print("sint", read_sint(s, length))
|
||||
elif elem.valtype == "float":
|
||||
print("float", read_float(s, length))
|
||||
elif elem.valtype == "skip":
|
||||
read(s, length)
|
||||
else:
|
||||
raise NotImplementedError
|
||||
else:
|
||||
print(" " * depth, '[' + elid + '] Unknown element! size:', length)
|
||||
print(" " * depth, "[" + elid + "] Unknown element! size:", length)
|
||||
read(s, length)
|
||||
return this_length
|
||||
|
||||
@@ -474,9 +474,9 @@ if __name__ == "__main__":
|
||||
def parse_toplevel(s):
|
||||
parse_one(s, 0, None, 1 << 63)
|
||||
|
||||
if sys.argv[1] == '--generate-header':
|
||||
if sys.argv[1] == "--generate-header":
|
||||
generate_C_header(open(sys.argv[2], "w"))
|
||||
elif sys.argv[1] == '--generate-definitions':
|
||||
elif sys.argv[1] == "--generate-definitions":
|
||||
generate_C_definitions(open(sys.argv[2], "w"))
|
||||
else:
|
||||
s = open(sys.argv[1], "rb")
|
||||
|
||||
+9
-9
@@ -13,10 +13,10 @@ def bundle_name(binary_name):
|
||||
return os.path.basename(bundle_path(binary_name))
|
||||
|
||||
def target_plist(binary_name):
|
||||
return os.path.join(bundle_path(binary_name), 'Contents', 'Info.plist')
|
||||
return os.path.join(bundle_path(binary_name), "Contents", "Info.plist")
|
||||
|
||||
def target_directory(binary_name):
|
||||
return os.path.join(bundle_path(binary_name), 'Contents', 'MacOS')
|
||||
return os.path.join(bundle_path(binary_name), "Contents", "MacOS")
|
||||
|
||||
def target_binary(binary_name):
|
||||
return os.path.join(target_directory(binary_name),
|
||||
@@ -26,7 +26,7 @@ def copy_bundle(binary_name, src_path):
|
||||
if os.path.isdir(bundle_path(binary_name)):
|
||||
shutil.rmtree(bundle_path(binary_name))
|
||||
shutil.copytree(
|
||||
os.path.join(src_path, 'TOOLS', 'osxbundle', bundle_name(binary_name)),
|
||||
os.path.join(src_path, "TOOLS", "osxbundle", bundle_name(binary_name)),
|
||||
bundle_path(binary_name))
|
||||
|
||||
def copy_binary(binary_name):
|
||||
@@ -34,21 +34,21 @@ def copy_binary(binary_name):
|
||||
|
||||
def apply_plist_template(plist_file, version):
|
||||
for line in fileinput.input(plist_file, inplace=1):
|
||||
print(line.rstrip().replace('${VERSION}', version))
|
||||
print(line.rstrip().replace("${VERSION}", version))
|
||||
|
||||
def sign_bundle(binary_name):
|
||||
sign_directories = ['Contents/Frameworks', 'Contents/MacOS']
|
||||
sign_directories = ["Contents/Frameworks", "Contents/MacOS"]
|
||||
for dir in sign_directories:
|
||||
resolved_dir = os.path.join(bundle_path(binary_name), dir)
|
||||
for root, _dirs, files in os.walk(resolved_dir):
|
||||
for f in files:
|
||||
path = os.path.join(root, f)
|
||||
subprocess.run(['codesign', '--force', '-s', '-', path])
|
||||
subprocess.run(['codesign', '--force', '-s', '-', bundle_path(binary_name)])
|
||||
subprocess.run(["codesign", "--force", "-s", "-", path])
|
||||
subprocess.run(["codesign", "--force", "-s", "-", bundle_path(binary_name)])
|
||||
|
||||
def bundle_version(src_path):
|
||||
version = 'UNKNOWN'
|
||||
version_path = os.path.join(src_path, 'MPV_VERSION')
|
||||
version = "UNKNOWN"
|
||||
version_path = os.path.join(src_path, "MPV_VERSION")
|
||||
if os.path.exists(version_path):
|
||||
x = open(version_path)
|
||||
version = x.read()
|
||||
|
||||
+6
-6
@@ -149,8 +149,8 @@ for e, index in zip(G.sevents, range(len(G.sevents))):
|
||||
else:
|
||||
e.vals = [(x, y * (m - index) / m) for (x, y) in e.vals]
|
||||
|
||||
pg.setConfigOption('background', 'w')
|
||||
pg.setConfigOption('foreground', 'k')
|
||||
pg.setConfigOption("background", "w")
|
||||
pg.setConfigOption("foreground", "k")
|
||||
app = QtWidgets.QApplication([])
|
||||
win = pg.GraphicsLayoutWidget()
|
||||
win.show()
|
||||
@@ -172,13 +172,13 @@ for e in G.sevents:
|
||||
cur = ax[1 if e.type == "value" else 0]
|
||||
if cur not in G.curveno:
|
||||
G.curveno[cur] = 0
|
||||
args = {'name': e.name,'antialias':True}
|
||||
args = {"name": e.name,"antialias":True}
|
||||
color = mkColor(colors[G.curveno[cur] % len(colors)])
|
||||
if e.type == "event-signal":
|
||||
args['symbol'] = e.marker
|
||||
args['symbolBrush'] = pg.mkBrush(color, width=0)
|
||||
args["symbol"] = e.marker
|
||||
args["symbolBrush"] = pg.mkBrush(color, width=0)
|
||||
else:
|
||||
args['pen'] = pg.mkPen(color, width=0)
|
||||
args["pen"] = pg.mkPen(color, width=0)
|
||||
G.curveno[cur] += 1
|
||||
cur.plot(*zip(*e.vals), **args)
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ def do_lint(commit_range: str) -> bool:
|
||||
print(f"Linting {len(commits)} commit(s):")
|
||||
any_failed = False
|
||||
for commit in commits:
|
||||
sha, _, _ = commit.partition(' ')
|
||||
sha, _, _ = commit.partition(" ")
|
||||
body = call(["git", "show", "-s", "--format=%B", sha]).splitlines()
|
||||
failed = []
|
||||
if len(body) == 0:
|
||||
@@ -79,7 +79,7 @@ def description_lowercase(body):
|
||||
|
||||
@lint_rule("Subject line must not end with a full stop")
|
||||
def no_dot(body):
|
||||
return not body[0].rstrip().endswith('.')
|
||||
return not body[0].rstrip().endswith(".")
|
||||
|
||||
@lint_rule("There must be an empty line between subject and extended description")
|
||||
def empty_line(body):
|
||||
|
||||
@@ -5,4 +5,5 @@ line-length = 100
|
||||
select = [
|
||||
"F", # pyflakes
|
||||
"E", "W", # pycodestyle
|
||||
"Q", # flake8-quotes
|
||||
]
|
||||
Reference in new issue
Block a user