Commit ec714a6d authored by Maximilian Dolling's avatar Maximilian Dolling

added config validation

parent 9a0715c0
......@@ -4,4 +4,9 @@
.idea
venv
__pycache__
\ No newline at end of file
__pycache__
test/tmp_test_report.md
meta/list-authors
meta/list-used-languages
meta/list-used-licenses
meta/reuse-lint
\ No newline at end of file
......@@ -26,34 +26,33 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# from schema import Schema, And, Use, Optional
# import yaml
#
# schema = Schema({'list-used-licenses': {'exclude': [str],
# 'rename': {'lib': {str: {str: str}}},
# 'local_imports': {str: [str]}},
# 'apply-license': {'description': str,
# 'copyright': str,
# 'time': str,
# 'maintainer': {'name': str,
# 'mail': str},
# 'licenses': {'data': {'spdx-identifier': str,
# 'copyright': str},
# 'software': {'spdx-identifier': str,
# 'copyright': str},
# 'pictures': {'spdx-identifier': str,
# 'copyright': str},
# 'insignificant': {'spdx-identifier': str,
# 'copyright': str}}}})
#
# with open('/repo/.sqa/config.yml') as config_yaml:
# config = yaml.load(config_yaml, Loader=yaml.FullLoader)
# config_yaml.close()
#
# validated = schema.validate(data)
#
# assert validated == [{'name': 'Sue', 'age': 28, 'gender': 'squid'},
# {'name': 'Sam', 'age': 42},
# {'name': 'Sacha', 'age': 20, 'gender': 'kid'}]
from schema import Schema, And, Use, Optional
import yaml
import sys
config_schema = Schema({'list-used-licenses': {'exclude': [str],
'rename': {'lib': {str: {str: str}}},
'local_imports': {str: [str]}},
'apply-license': {'description': str,
'copyright': str,
'time': str,
'maintainer': {'name': str,
'mail': str},
'licenses': {'data': {'spdx-identifier': str,
'copyright': str},
'software': {'spdx-identifier': str,
'copyright': str},
'pictures': {'spdx-identifier': str,
'copyright': str},
'insignificant': {'spdx-identifier': str,
'copyright': str}}}})
with open('/repo/.sqa/config.yml') as config_yaml:
config = yaml.load(config_yaml, Loader=yaml.FullLoader)
config_yaml.close()
print('config valid...')
if config_schema.is_valid(config):
print('config is valid')
else:
print('config is not valid')
sys.exit(1)
\ No newline at end of file
......@@ -70,7 +70,7 @@ SPDX-License-Identifier: CC0-1.0
|---|---|---|
|Apache 2.0|1|requests|
|GPL-3.0-or-later AND Apache-2.0 AND CC0-1.0 AND CC-BY-SA-4.0|1|reuse|
|MIT|3|PyYAML <br> httpretty <br> stdlib-list|
|MIT|4|PyYAML <br> httpretty <br> schema <br> stdlib-list|
|Python-2.0|10|datetime <br> importlib <br> json <br> os <br> pathlib <br> re <br> shutil <br> sys <br> time <br> unittest|
|mock|1|stdlib|
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment