where is the "BaseHandler.__init__" exec ?
Jian Lee
lijian.gnu at gmail.com
Wed Apr 28 10:43:29 UTC 2010
hi,all
I'm research pykickstart now, have a puzzle on pykickstart/version.py .
where is the "BaseHandler.__init__" exec ?
look at the following code, after func "returnClassForVersion" have executed,
the "commands" attr of "handler" have fixed by "command-object" mapping already.
but from the line 173 to 177, there is just a imputil.imp.load_module func ,
and the module itself haven't execute a "BaseHandler.__init__" func.
how the "handler" get a fixed attr "commands" ?
Thanks,
-------------------------------------------------------------------
159 def returnClassForVersion(version=DEVEL):
160 """Return the class of the syntax handler for version. version can be
161 either a string or the matching constant. Raises KickstartValueError
162 if version does not match anything.
163 """
164 try:
165 version = int(version)
166 module = "%s" % versionToString(version, skipDevel=True)
167 except ValueError:
168 module = "%s" % version
169 version = stringToVersion(version)
170
171 module = module.lower()
172
173 try:
174 import pykickstart.handlers
175 sys.path.extend(pykickstart.handlers.__path__)
176 found = imputil.imp.find_module(module)
177 loaded = imputil.imp.load_module(module, found[0], found[1], found[2])
178
179 for (k, v) in loaded.__dict__.iteritems():
180 if k.lower().endswith("%shandler" % module):
181 return v
182 except:
183 raise KickstartVersionError(_("Unsupported version specified: %s") % version)
=====================================================
---------------------
Jian Lee [ http://jianlee.ylinux.org ]
More information about the Kickstart-list
mailing list