diff --git a/.flake8 b/.flake8 index 459cc557..fa51876f 100644 --- a/.flake8 +++ b/.flake8 @@ -41,3 +41,6 @@ copyright-text = '#' '# SPDX-License-Identifier: Apache-2.0' '# Copyright (c) OWASP Foundation. All Rights Reserved.' +lines-to-exclude = + ## shebang + '#!' diff --git a/tools/schema-downloader.py b/tools/schema-downloader.py old mode 100644 new mode 100755 index d9e4a31c..d795f474 --- a/tools/schema-downloader.py +++ b/tools/schema-downloader.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + # This file is part of CycloneDX Python Library # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,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'], @@ -99,14 +101,16 @@ source = dspec['sourcePattern'].replace('%s', version) target = dspec['targetPattern'].replace('%s', version) tempfile, _ = urlretrieve(source) # nosec B310 + print(source, '->', target) with open(tempfile, 'r') as tmpf: - with open(target, 'w', newline='\n') as tarf: - text = tmpf.read() - for search, replace in dspec['replace']: - text = text.replace(search, replace) - for search, replace in dspec['replaceRE']: - text = search.sub(replace, text) - tarf.write(text) + text = tmpf.read() + with open(target, 'w', newline='\n') as tarf: + for search, replace in dspec['replace']: + text = text.replace(search, replace) + for search, replace in dspec['replaceRE']: + text = search.sub(replace, text) + tarf.write(text) for source, target in OTHER_DOWNLOADABLES: + print(source, '->', target) urlretrieve(source, target) # nosec B310