5 """ Support for command line options.
9 # m_options -- option object (returned by optparse.parse_args)
10 # m_args -- arguments list (returned by optparse.parse_args)
11 # m_parser -- option parser
17 def getOptionActive(optionName
):
18 """ Returns true if the given option is active
20 if optionName
in OptionHandler
.m_options
.__dict
__:
21 optionVal
= OptionHandler
.m_options
.__dict
__[optionName
];
23 if (optionVal
!= None) and (optionVal
!= False):
28 getOptionActive
= staticmethod(getOptionActive
);
30 def getOptionArg(optionName
):
31 """ Returns the argument of an option
33 if optionName
in OptionHandler
.m_options
.__dict
__:
34 return OptionHandler
.m_options
.__dict
__[optionName
];
38 getOptionArg
= staticmethod(getOptionArg
);
41 """ Low level access to the options dictionary.
43 return OptionHandler
.m_options
;
45 getOptionList
= staticmethod(getOptionList
);
48 """ Low level access to the arguments list.
50 return OptionHandler
.m_args
;
52 getArgList
= staticmethod(getArgList
);
55 """ Setup option parser
57 if OptionHandler
.m_parser
!= None:
58 print "WARNING: OptionHandler.setup: Called twice.";
61 OptionHandler
.m_parser
= optparse
.OptionParser();
63 OptionHandler
.m_parser
.add_option(
68 help="FieldContainer description file.",
71 OptionHandler
.m_parser
.add_option(
75 help="write the FieldContainerBase files. [default: false].");
77 OptionHandler
.m_parser
.add_option(
81 help="write the FieldContainer files. [default: false].");
83 OptionHandler
.m_parser
.add_option(
88 help="destination path for files.",
91 OptionHandler
.m_parser
.add_option(
96 help="root of the OpenSG source tree.",
99 OptionHandler
.m_parser
.add_option(
100 "-t", "--template-path",
104 help="path to where the fcd2code templates are stored.",
107 OptionHandler
.m_parser
.add_option(
111 help="print diagnostic messages. [default: false].");
113 OptionHandler
.m_parser
.add_option(
114 "-c", "--compat-mode",
117 help="enable 1.x compatibility mode. [default: false].");
119 OptionHandler
.m_parser
.add_option(
123 help="create field bundle. [default: false].");
125 OptionHandler
.m_parser
.set_defaults(writeBase
=False);
126 OptionHandler
.m_parser
.set_defaults(writeFC
=False);
127 OptionHandler
.m_parser
.set_defaults(verbose
=False);
129 setup
= staticmethod(setup
);
132 """ Parse command line arguments.
134 if OptionHandler
.m_parser
== None:
135 print "WARNING: OptionHandler.parse: no parser, run setup first.";
138 (options
, args
) = OptionHandler
.m_parser
.parse_args(args
);
140 OptionHandler
.m_options
= options
;
141 OptionHandler
.m_args
= args
;
143 parse
= staticmethod(parse
);