[PR PATCH] python: Add argparse samba options
github at samba.org
github at samba.org
Tue May 8 18:58:45 UTC 2018
There is a new pull request by dmulder against master on the Samba Samba Github repository
https://github.com/dmulder/samba argparse_getarg
https://github.com/samba-team/samba/pull/178
python: Add argparse samba options
Creates samba.getarg, which mirrors the options in samba.getopt, accept these options work with the newer python argparse module (since optparse has been deprecated for some time).
import argparse
from samba import getarg as options
parser = argparse.ArgumentParser('program')
sambaopts = options.SambaOptions(parser)
credopts = options.CredentialsOptions(parser)
options.add_argument_group(parser, sambaopts)
options.add_argument_group(parser, credopts)
options.add_argument_group(parser, options.VersionOptions(parser))
There is nothing like optparse.add_option_group() anymore, argparse.add_argument_group() only accepts the parameters to the _ArgumentGroup class, instead of an instance of _ArgumentGroup. This is the reason for options.add_argument_group().
Also, the only way to write a callback is to implement an Action in argparse, hence the store() and store_true() generators.
A patch file from https://github.com/samba-team/samba/pull/178.patch is attached
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: github-pr-argparse_getarg-178.patch
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20180508/0aa56df0/github-pr-argparse_getarg-178.patch>
More information about the samba-technical
mailing list