455
456
def version_info(self):
456
457
"""Return the plugin's version_tuple or None if unknown."""
457
458
version_info = getattr(self.module, 'version_info', None)
458
if version_info is not None and len(version_info) == 3:
459
version_info = tuple(version_info) + ('final', 0)
459
if version_info is not None:
461
if isinstance(version_info, types.StringType):
462
version_info = version_info.split('.')
463
elif len(version_info) == 3:
464
version_info = tuple(version_info) + ('final', 0)
466
# The given version_info isn't even iteratible
467
trace.log_exception_quietly()
468
version_info = (version_info,)
460
469
return version_info
462
471
def _get__version__(self):
463
472
version_info = self.version_info()
464
if version_info is None:
473
if version_info is None or len(version_info) == 0:
466
if version_info[3] == 'final':
467
version_string = '%d.%d.%d' % version_info[:3]
469
version_string = '%d.%d.%d%s%d' % version_info
476
version_string = _format_version_tuple(version_info)
477
except (ValueError, TypeError, IndexError), e:
478
trace.log_exception_quietly()
479
# try to return something usefull for bad plugins, in stead of
481
version_string = '.'.join(map(str, version_info))
470
482
return version_string
472
484
__version__ = property(_get__version__)