def __str__(self): msg = '{}'.format(self.name) if self.version: msg += '-{}'.format(self.version) if self.source: msg += ' from {}'.format(self.source) tips = 'No HubModule named {} was found'.format(log.FormattedText(text=msg, color='red')) if self.info: sort_infos = sorted(self.info.items(), key=lambda x: utils.Version(x[0])) table = log.Table() table.append( *['Name', 'Version', 'PaddlePaddle Version Required', 'PaddleHub Version Required'], widths=[15, 10, 35, 35], aligns=['^', '^', '^', '^'], colors=['cyan', 'cyan', 'cyan', 'cyan']) for _ver, info in sort_infos: paddle_version = 'Any' if not info['paddle_version'] else ', '.join(info['paddle_version']) hub_version = 'Any' if not info['hub_version'] else ', '.join(info['hub_version']) table.append(self.name, _ver, paddle_version, hub_version, aligns=['^', '^', '^', '^']) tips += ':\n{}'.format(table) return tips
def __str__(self): msg = '{}'.format(self.name) if self.version: msg += '-{}'.format(self.version) tips = '{} cannot be installed because some conditions are not met'.format( log.FormattedText(text=msg, color='red')) if self.info: sort_infos = sorted(self.info.items(), key=lambda x: utils.Version(x[0])) table = log.Table() table.append( *['Name', 'Version', 'PaddlePaddle Version Required', 'PaddleHub Version Required'], widths=[15, 10, 35, 35], aligns=['^', '^', '^', '^'], colors=['cyan', 'cyan', 'cyan', 'cyan']) import paddle import paddlehub for _ver, info in sort_infos: paddle_version = 'Any' if not info['paddle_version'] else ', '.join(info['paddle_version']) for version in info['paddle_version']: if not utils.Version(paddle.__version__).match(version): paddle_version = '{}(Mismatch)'.format(paddle_version) break hub_version = 'Any' if not info['hub_version'] else ', '.join(info['hub_version']) for version in info['hub_version']: if not utils.Version(paddlehub.__version__).match(version): hub_version = '{}(Mismatch)'.format(hub_version) break table.append(self.name, _ver, paddle_version, hub_version, aligns=['^', '^', '^', '^']) tips += ':\n{}'.format(table) return tips