Skip to content

Commit 3369a6a

Browse files
authored
chore: tools shebang (#770)
Signed-off-by: Jan Kowalleck <[email protected]>
1 parent 472bded commit 3369a6a

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

.flake8

+3
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ copyright-text =
4141
'#'
4242
'# SPDX-License-Identifier: Apache-2.0'
4343
'# Copyright (c) OWASP Foundation. All Rights Reserved.'
44+
lines-to-exclude =
45+
## shebang
46+
'#!'

tools/schema-downloader.py

100644100755
+13-9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env python3
2+
13
# This file is part of CycloneDX Python Library
24
#
35
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,11 +18,11 @@
1618
# Copyright (c) OWASP Foundation. All Rights Reserved.
1719

1820
import re
19-
from os.path import dirname, join
21+
from os.path import dirname, join, realpath
2022
from urllib.request import urlretrieve
2123

2224
SOURCE_ROOT = 'https://raw.githubusercontent.com/CycloneDX/specification/refs/tags/1.6.1/schema/'
23-
TARGET_ROOT = join(dirname(__file__), '..', 'cyclonedx', 'schema', '_res')
25+
TARGET_ROOT = realpath(join(dirname(__file__), '..', 'cyclonedx', 'schema', '_res'))
2426

2527
BOM_XSD = {
2628
'versions': ['1.6', '1.5', '1.4', '1.3', '1.2', '1.1', '1.0'],
@@ -99,14 +101,16 @@
99101
source = dspec['sourcePattern'].replace('%s', version)
100102
target = dspec['targetPattern'].replace('%s', version)
101103
tempfile, _ = urlretrieve(source) # nosec B310
104+
print(source, '->', target)
102105
with open(tempfile, 'r') as tmpf:
103-
with open(target, 'w', newline='\n') as tarf:
104-
text = tmpf.read()
105-
for search, replace in dspec['replace']:
106-
text = text.replace(search, replace)
107-
for search, replace in dspec['replaceRE']:
108-
text = search.sub(replace, text)
109-
tarf.write(text)
106+
text = tmpf.read()
107+
with open(target, 'w', newline='\n') as tarf:
108+
for search, replace in dspec['replace']:
109+
text = text.replace(search, replace)
110+
for search, replace in dspec['replaceRE']:
111+
text = search.sub(replace, text)
112+
tarf.write(text)
110113

111114
for source, target in OTHER_DOWNLOADABLES:
115+
print(source, '->', target)
112116
urlretrieve(source, target) # nosec B310

0 commit comments

Comments
 (0)