-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
schemagen: remove xsdata[cli] from requirements, add copyright notice…
…, black Signed-off-by: Jean-Louis Leroy <jleroy9@bloomberg.net>
- Loading branch information
Showing
2 changed files
with
49 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,61 @@ | ||
#! /usr/bin/env bash | ||
|
||
# This script generates Python classes corresponding to 'mqbcfg.xsd' and | ||
# 'mqbconf.xsd' | ||
|
||
set -e | ||
|
||
this=$(dirname "$0") | ||
python_root=$(realpath "${this}"/..) | ||
blazingmq_root=$(realpath "${python_root}/../..") | ||
|
||
if [ ! "$(which xsdata)" ]; then | ||
echo "'xsdata' is required" | ||
if ! command -v xsdata; then | ||
cat <<ERROR | ||
This script requires 'xsdata[cli]', which is not listed in | ||
src/python/requirements.txt because it depends on Rust, which may not be | ||
available in certain environments. Please install 'xsdata[cli]' manually with: | ||
pip install 'xsdata[cli]' | ||
...and try again. | ||
ERROR | ||
exit 1 | ||
fi | ||
|
||
copyright=$(cat <<COPYRIGHT | ||
# Copyright 2024 Bloomberg Finance L.P. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
COPYRIGHT | ||
) | ||
|
||
cd "${python_root}" | ||
xsdata generate --package blazingmq.schemas "${blazingmq_root}/src/groups/mqb/mqbcfg/mqbcfg.xsd" | ||
xsdata generate --package blazingmq.schemas "${blazingmq_root}/src/groups/mqb/mqbconfm/mqbconf.xsd" | ||
|
||
|
||
function copyright_black { | ||
echo "$copyright | ||
$(cat $1)" > $1 | ||
black -q $1 | ||
black -q $1 | ||
} | ||
|
||
function generate { | ||
xsdata generate --package blazingmq.schemas "$1" | ||
copyright_black $2 | ||
} | ||
|
||
generate "${blazingmq_root}/src/groups/mqb/mqbcfg/mqbcfg.xsd" blazingmq/schemas/mqbcfg.py | ||
generate "${blazingmq_root}/src/groups/mqb/mqbconfm/mqbconf.xsd" blazingmq/schemas/mqbconf.py | ||
copyright_black blazingmq/schemas/__init__.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,3 @@ pytest-xdist | |
pyyaml | ||
termcolor | ||
xsdata | ||
xsdata[cli] |