Mercurial > cgi-bin > hgweb.cgi > tincan
comparison tincan.py @ 14:9d0497dc19f8 draft
Ack! Think this is the way to introspect.
author | David Barts <n5jrn@me.com> |
---|---|
date | Thu, 16 May 2019 12:04:20 -0700 |
parents | 6de828de4409 |
children | 560c8fb55e4a |
comparison
equal
deleted
inserted
replaced
13:6de828de4409 | 14:9d0497dc19f8 |
---|---|
464 except Exception as e: | 464 except Exception as e: |
465 raise TinCanError("{0}: error importing".format(pycpath)) from e | 465 raise TinCanError("{0}: error importing".format(pycpath)) from e |
466 self._class = None | 466 self._class = None |
467 for i in dir(mod): | 467 for i in dir(mod): |
468 v = getattr(mod, i) | 468 v = getattr(mod, i) |
469 if isclass(v) and issubclass(v, klass) and v is not klass: | 469 if isclass(v) and issubclass(v, klass): |
470 if self._class is not None and self._class is not klass: | 470 if self._class is None: |
471 raise TinCanError("{0}: contains multiple {1} classes".format(pypath, klass.__name__)) | 471 self._class = v |
472 self._class = v | 472 else: |
473 if self._class is klass: | |
474 self._class = v | |
475 elif v is not klass: | |
476 raise TinCanError("{0}: contains multiple {1} classes".format( | |
477 pypath, klass.__name__)) | |
473 if self._class is None: | 478 if self._class is None: |
474 raise TinCanError("{0}: contains no {1} classes".format(pypath, klass.__name__)) | 479 raise TinCanError("{0}: contains no {1} classes".format(pypath, klass.__name__)) |
475 | 480 |
476 def _redirect(self): | 481 def _redirect(self): |
477 try: | 482 try: |