pyang icon indicating copy to clipboard operation
pyang copied to clipboard

yang2dsdl does not search virtualenv path for xslt

Open choppsv1 opened this issue 5 years ago • 2 comments

This is a re-opening of #499 as I do not believe it should have been closed.

The close comment was: "yang2dsdl is a shell script that uses xsltproc for XSLT processing, which knows nothing about Python virtualenv."

The project is pyang, what the individual tool (yang2dsdl) is written in, or uses to do it job is irrelevant to the bug. It cannot find it's own files.

Why can't pyang just have yang2dsdl set/add-to PYANG_XSLT_DIR to include the directory that pyang has installed the xslt in?

choppsv1 avatar Sep 22 '19 12:09 choppsv1

I marked this as help wanted. I am not very familiar with virtualenv and what can be done. So if you have an idea for how it can be solved, it would be much appreciated!

mbj4668 avatar Oct 17 '19 11:10 mbj4668

There are so many permutations of pkg install options I get confused.. but maybe something like this would work?

(default) [08:50:51 dak:~/w/pyang]$ git diff
diff --git a/bin/yang2dsdl b/bin/yang2dsdl
index 7c2a1dc..c0ab99c 100755
--- a/bin/yang2dsdl
+++ b/bin/yang2dsdl
@@ -31,6 +31,14 @@ jing=0
 xslt_dir=${PYANG_XSLT_DIR:-/usr/local/share/yang/xslt}
 schema_dir=${PYANG_RNG_LIBDIR:-/usr/local/share/yang/schema}

+sysprefix="$(/usr/bin/env python -c 'import sys; print(sys.prefix)')"
+if [ -n "$sysprefix" ]; then
+    if [ -d "$sysprefix/share/yang/xslt" ]; then
+        xslt_dir=${PYANG_XSLT_DIR:-"$sysprefix/share/yang/xslt"}
+        schema_dir=${PYANG_RNG_LIBDIR:-"$sysprefix/share/yang/schema"}
+    fi
+fi
+
 usage() {
     cat <<EOF

choppsv1 avatar Oct 21 '19 12:10 choppsv1