mbj4668 / pyang

An extensible YANG validator and converter in python
ISC License
537 stars 344 forks source link

yang2dsdl does not search virtualenv path for xslt #499

Closed choppsv1 closed 5 years ago

choppsv1 commented 5 years ago

yang2dsdl does not search in python virtual environment for xslt files

(default) [05:43:51 dak:~]$ ls -l ~/Envs/default/share/yang/xslt/
total 220
-rw-r--r-- 1 chopps users   544 Jun 11 23:52 basename.xsl
-rw-r--r-- 1 chopps users  3426 Jun 11 23:52 dsrl2xslt.xsl
...
(default) [05:43:59 dak:~]$ which yang2dsdl
/home/chopps/Envs/default/bin/yang2dsdl
(default) [05:34:20 dak:~/w/lisp-yang]$ yang2dsdl -x -t config -d .validate -v test-xml-example.xml ietf-lisp.yang
warning: failed to load external entity "/usr/local/share/yang/xslt/basename.xsl"
cannot parse /usr/local/share/yang/xslt/basename.xsl
...
llhotka commented 5 years ago

yang2dsdl is a shell script that uses xsltproc for XSLT processing, which knows nothing about Python virtualenv. The solution is to set the environment variable PYANG_XSLT_DIR to the directory within the virtualenv in which the pyang XSLT stylesheets reside.

choppsv1 commented 5 years ago

I don't care what yang2dsdl is written in or does to implement it's functionality, I run it it doesn't find it's own files, I say that's broken. :)

If I was going to fix this I'd have yang2dsdl set/add-to PYANG_XSLT_DIR to include the directory that pyang has installed the xslt in.

choppsv1 commented 5 years ago

Since no reply I'll open a new issue. :)

Santhoshexp commented 2 years ago

yang2dsdl is a shell script that uses xsltproc for XSLT processing, which knows nothing about Python virtualenv. The solution is to set the environment variable PYANG_XSLT_DIR to the directory within the virtualenv in which the pyang XSLT stylesheets reside.

Can you explain in detail

llhotka commented 2 years ago

For example, my .bashrc file contains the line

export PYANG_XSLT_DIR=$HOME/Projects/pyang/xslt
Santhoshexp commented 2 years ago

For example, my .bashrc file contains the line

export PYANG_XSLT_DIR=$HOME/Projects/pyang/xslt

Yep this worked✌️

maksim-estonia commented 2 years ago

This worked for me:

gedit ~/.bashrc

And add following lines:

export PYANG_XSLT_DIR=$HOME/pyang/xslt
export PYANG_RNG_LIBDIR=$HOME/pyang/schema
wlupton commented 2 years ago

Note that env.sh includes these lines:

export PYANG_XSLT_DIR="$PWD/xslt"
export PYANG_RNG_LIBDIR="$PWD/schema"
maksim-estonia commented 2 years ago

Hi,

Yes, but I think my issue was caused due to the following lines in yang2dsdl:

xslt_dir=${PYANG_XSLT_DIR:-/usr/local/share/yang/xslt}
schema_dir=${PYANG_RNG_LIBDIR:-/usr/local/share/yang/schema}