Re: omniORBpy: string to omniORB.EnumItem instance

chris williams via omniORB-list <[email protected]> Mon, 12 Feb 2018 10:06:01 -0500
Newsgroups gmane.comp.corba.omniorb.user
Message-ID <CAN0Sa0wg5gXaRzBDxU1SX+Te2-gdPdAioRrWXvf=hcUymukSzQ@mail.gmail.com>
thanks!

Chris Williams
Senior Web Developer
Clearwater, FL
731-445-4904

On Mon, Feb 12, 2018 at 5:21 AM, Duncan Grisby <[email protected]> wrote:

> On Tue, 2018-01-30 at 16:30 -0500, chris williams via omniORB-list
> wrote:
>
> > Is it possible to convert a string to omniORB.EnumItem instance ?  I
> > want to be able to accept a command line parameter and convert that
> > to enum.
> >
> > I have an enum defined as such in IDL:
> >
> > enum IdlCommandType
> > {
> >    IDL_SETTINGS,
> >    IDL_STATS
> >
> > }
> >
> > If I accept a command line parameter  "IDL_SETTINGS" (as a string),
> > what is the python code to convert this to
> > type _GlobalIDL.IDL_SETTINGS ?
>
> That's just standard simple Python:
>
>   param = # the parameter from the command line
>   item  = getattr(_GlobalIDL, param)
>
>
> If you want to check that the value really does belong to the right
> enum, you can see if it is in the items:
>
>   if item in _GlobalIDL.IdlCommandType._items:
>       # It was a valid enum item
>
>
> Duncan.
>
> --
>  -- Duncan Grisby         --
>   -- [email protected]     --
>    -- http://www.grisby.org --
>
>

_______________________________________________
omniORB-list mailing list
[email protected]
http://www.omniorb-support.com/mailman/listinfo/omniorb-list