Open wivory opened 5 years ago
Off the top of my head (i.e. I haven't checked) I don't think that the path is considered when opening files specified on the command line. Therefore it opens the file in the current directory simply because the file (as specified on the command line) exists.
Oh, and please note that recent pyang versions when run with the --verbose
(-V
) option will output a list of files as it opens them (with (CL)
for files specified on the command line and, I seem to recall, upper-case READ
if the file's already been read).
Example:
% pyang --verbose ./bbf-fast.yang
# read ./bbf-fast.yang (CL)
# read bbf-fast-base.yang
# read /Users/william/Documents/BBF/Standards/pyang/modules/ietf/ietf-interfaces.yang
# read /Users/william/Documents/BBF/Standards/pyang/modules/ietf/ietf-yang-types.yang
# read bbf-fastdsl.yang
# read /Users/william/Documents/BBF/Standards/pyang/modules/iana/iana-if-type.yang
# read bbf-fast-pointers.yang
# read bbf-fast-service-profiles.yang
# read bbf-fast-data-rate-profile-body.yang
# read bbf-fast-spectrum-profiles.yang
...
So if you run pyang with a file / files specified, it reads in those and anything it can find in the working directory, but if you run pyang with no files specified, it waits for input from stdin (rather than reading in files in the working directory). That doesn't seem very consistent to me, though if that's the way it is designed I can work around it by changing the working directory. Just caught me by surprise ... William On Wed, 2019-07-31 at 08:58 -0700, William Lupton wrote:
Oh, and please note that recent pyang versions when run with the -- verbose (-V) option will output a list of files as it opens them (with (CL) for files specified on the command line and, I seem to recall, upper-case READ if the file's already been read).
Example:
% pyang --verbose ./bbf-fast.yang # read ./bbf-fast.yang (CL)# read bbf-fast-base.yang# read /Users/william/Documents/BBF/Standards/pyang/modules/ietf/ietf- interfaces.yang# read /Users/william/Documents/BBF/Standards/pyang/modules/ietf/ietf-yang- types.yang# read bbf-fastdsl.yang# read /Users/william/Documents/BBF/Standards/pyang/modules/iana/iana-if- type.yang# read bbf-fast-pointers.yang# read bbf-fast-service- profiles.yang# read bbf-fast-data-rate-profile-body.yang# read bbf- fast-spectrum-profiles.yang...
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
[ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": " https://github.com/mbj4668/pyang/issues/502?email_source=notifications\u0026email_token=AEUR24ZKZGEVUNZVYPQ7OFDQCGZDRA5CNFSM4IIGT7I2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3HXHJA#issuecomment-516912036 ", "url": " https://github.com/mbj4668/pyang/issues/502?email_source=notifications\u0026email_token=AEUR24ZKZGEVUNZVYPQ7OFDQCGZDRA5CNFSM4IIGT7I2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3HXHJA#issuecomment-516912036 ", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]
Not sure what you mean with "pulls in the file in the local directory". pyang searches the current directory for imported modules.
I know this is an old issue, but is there a way to prevent this behaviour?
I'm running pyang with a list of modules of the command line. However, if pyang sees that there is a newer revision it will read that one as well and use the newer revision instead.
$ pyang -V -f tree -p $PYANG_PATH ... node@2020-06-12.yang ...
# read node@2020-06-12.yang (CL)
...
# read node@2021-02-04.yang
The only workaround I've found is to manually specify revision-dates on all imports of that module in the code, which is not ideal.
This might be related to issue #684?
Apologies if this is user misunderstanding - I am seeing that if I run pyang in a directory that contains a YANG file, then even when run specifying both '-p' and path to yang files, pyang pulls in the file in the local directory.
[run from directory other than the one listed in the command]:
/usr/bin/pyang --strict -p ~/Downloads/ISOs/resources/yang ~/Downloads/ISOs/resources/yang/*.yang
We only realised this was happening when we had a YANG file in the working directory with a YANG bug in it. Is this expected behaviour or a bug?