Coverage for mfplugin/cli_tools/plugins_info.py: 0%
33 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-11-13 15:57 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-11-13 15:57 +0000
1#!/usr/bin/env python3
3from __future__ import print_function
4import os
5import argparse
6import sys
7import textwrap
8from terminaltables import DoubleTable
9from mfplugin.compat import get_plugin_info
11DESCRIPTION = "get some information about a plugin"
12MFMODULE_LOWERCASE = os.environ.get('MFMODULE_LOWERCASE', 'mfext')
15def main():
16 arg_parser = argparse.ArgumentParser(description=DESCRIPTION)
17 arg_parser.add_argument("name_or_filepath", type=str,
18 help="installed plugin name (without version) or "
19 "full plugin filepath")
20 arg_parser.add_argument("--just-home", action="store_true",
21 help="if set, just return plugin home")
22 arg_parser.add_argument("--plugins-base-dir", type=str, default=None,
23 help="can be use to set an alternate "
24 "plugins-base-dir, if not set the value of "
25 "MFMODULE_PLUGINS_BASE_DIR env var is used (or a "
26 "hardcoded standard value).")
27 args = arg_parser.parse_args()
29 infos = get_plugin_info(args.name_or_filepath,
30 plugins_base_dir=args.plugins_base_dir)
32 if infos is None:
33 sys.exit(1)
34 if args.just_home:
35 print(infos['home'])
36 sys.exit(0)
38 table_data = []
39 for title, key in [("Name", "name"), ("Version", "version"),
40 ("Release", "release"), ("Summary", "summary"),
41 ("Size", "size"),
42 ("Build Host", "build_host"),
43 ("Build Date", "build_date"),
44 ("License", "license"), ("Maintainer", "packager"),
45 ("Vendor", "vendor"), ("URL", "url")]:
46 table_data.append((title, textwrap.fill(infos['metadatas'][key], 60)))
47 t = DoubleTable(table_data=table_data)
48 t.inner_heading_row_border = False
49 print(t.table)
50 print()
51 print("Files:")
52 for f in infos['files']:
53 print("- %s" % f)
56if __name__ == '__main__':
57 main()