Skip to content

Commit

Permalink
output
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Kowalleck <[email protected]>
  • Loading branch information
jkowalleck committed Feb 4, 2025
1 parent 7dee855 commit 8867ec0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tools/schema-downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
# Copyright (c) OWASP Foundation. All Rights Reserved.

import re
from os.path import dirname, join
from os.path import dirname, join, realpath
from urllib.request import urlretrieve

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

BOM_XSD = {
'versions': ['1.6', '1.5', '1.4', '1.3', '1.2', '1.1', '1.0'],
Expand Down Expand Up @@ -101,8 +101,9 @@
source = dspec['sourcePattern'].replace('%s', version)
target = dspec['targetPattern'].replace('%s', version)
tempfile, _ = urlretrieve(source) # nosec B310
with open(tempfile, 'r') as tmpf:
with open(target, 'w', newline='\n') as tarf:
print(source, '->', target)
with open(tempfile, 'r') as tmpf, \
open(target, 'w', newline='\n') as tarf:
text = tmpf.read()
for search, replace in dspec['replace']:
text = text.replace(search, replace)
Expand Down

0 comments on commit 8867ec0

Please sign in to comment.