-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ensure pyang can be used embedded in another program #325
Comments
Are there any examples of using pyang as a library? Or is this currently not possible? |
If you want a documented Python library, Yangson is another option. Its aims and functionality are somewhat different though so it depends on what you need to do with it. |
@mbj4668 Is there any movement on this? Anything which could be done to assist? This would help greatly with the testing for |
I haven't had time to work on this. If you want to help, that'd be great! We should move from optparse to argparse, and move as much logic as possible from bin/pyang into the library. If you have a need for this ticket to be fixed, you probably know what needs to be done ;-) Here's some notes I wrote earlier: An application will have to do something like:
Currently, each plugin adds its own options to the optparse object, but if it called from within an application there won't be an optparse object. This might be ok, but then the plugins rely on the optparse.Value object to check what to do. Maybe it is ok if the application creates such an object itself, sets the option values it needs to set, and then continue? Or we could provide a pyang method that would create a suitable optparse.Value instance, with the default values pyang expects, for the application to retrieve and modify as desired. This would be backwards incompatible, and all plugins would have to be adjusted. Also, time to introduce a plugin API version, so that we can give a proper error message if an old plugin is being used with a newer version of pyang. |
The idea from the start was that all pyang functionality should be available to some other python program that just imports pyang. Unfortunately, over time too much logic is done in the executable script bin/pyang. This should be cleaned up.
The text was updated successfully, but these errors were encountered: