[omniORB] omniORBpy: string to omniORB.EnumItem instance

chris williams chrswilliams516 at gmail.com
Mon Feb 12 15:06:01 GMT 2018


thanks!

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

On Mon, Feb 12, 2018 at 5:21 AM, Duncan Grisby <duncan at grisby.org> 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         --
>   -- duncan at grisby.org     --
>    -- http://www.grisby.org --
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20180212/6b0dd8cb/attachment.html>


More information about the omniORB-list mailing list