From d4669e5c3497146577e34a117bcb0bcb4bceb0c9 Mon Sep 17 00:00:00 2001 From: Sunil Shetye Date: Thu, 2 Jan 2025 12:26:45 +0530 Subject: script to convert xml to xcos --- blocks/Xcos/XmlToXcos.sh | 62 +++++++++++++++++++++++++++++++++ blocks/eda-frontend/public/geometry.xsl | 12 ------- 2 files changed, 62 insertions(+), 12 deletions(-) create mode 100755 blocks/Xcos/XmlToXcos.sh diff --git a/blocks/Xcos/XmlToXcos.sh b/blocks/Xcos/XmlToXcos.sh new file mode 100755 index 00000000..e73f611d --- /dev/null +++ b/blocks/Xcos/XmlToXcos.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +usage() { + echo "Usage:" >&2 + echo " $0 input-file.xml" >&2 + exit 101 +} + +if test $# -ne 1; then + usage +fi + +INPUT="$1" +if test ! -f "$INPUT"; then + echo "$INPUT: not found" >&2 + usage +fi +if test "${INPUT%.xml}" != "$INPUT"; then + BASE="${INPUT%.xml}" + INPUT1="$INPUT" +else + echo "$INPUT: not xml" >&2 + usage +fi + +set -e + +TMPFILE2="$(mktemp -t XXXXXX.xml)" +trap "rm -f $TMPFILE2" 0 1 2 15 + +rm -f "$BASE."*.xml + +echo "Running Xcos/XmlParser.py $INPUT1" >&2 +Xcos/XmlParser.py "$INPUT1" >&2 && rv=$? || rv=$? + +while test $rv -gt 0; do + oldrv=$rv + + INPUT1="$BASE.$rv.xml" + echo "Created $INPUT1" >&2 + xmllint --format "$INPUT1" >"$TMPFILE2" + cp -f "$TMPFILE2" "$INPUT1" + echo "Running Xcos/XmlParser.py $INPUT1" >&2 + Xcos/XmlParser.py "$INPUT1" >&2 && rv=$? || rv=$? + + if ((rv >= oldrv)); then + echo "ERROR: $rv >= $oldrv" >&2 + exit 102 + fi +done + +INPUT1="$BASE.$rv.xml" +echo "Created $INPUT1" >&2 +xmllint --format "$INPUT1" >"$TMPFILE2" +cp -f "$TMPFILE2" "$INPUT1" + +echo "Running Xcos/MxGraphParser.py $INPUT1" >&2 +Xcos/MxGraphParser.py "$INPUT1" >&2 +INPUT1="$BASE.$rv.xcos" +echo "Created $INPUT1" >&2 + +exit 0 diff --git a/blocks/eda-frontend/public/geometry.xsl b/blocks/eda-frontend/public/geometry.xsl index 967a35b9..260c64e7 100644 --- a/blocks/eda-frontend/public/geometry.xsl +++ b/blocks/eda-frontend/public/geometry.xsl @@ -129,18 +129,6 @@ - - - - - - - -- cgit