src/eric7/PipInterface/piplicenses.py

branch
eric7
changeset 10881
c20d7e202152
parent 10756
0702be694bc4
child 11090
f5f5f5803935
equal deleted inserted replaced
10880:2d2dd2c638e8 10881:c20d7e202152
36 # - removed dependency to prettytable 36 # - removed dependency to prettytable
37 # - removed some not needed code 37 # - removed some not needed code
38 # - changed 'create_licenses_table' to 'create_licenses_list' 38 # - changed 'create_licenses_table' to 'create_licenses_list'
39 # - changed 'create_summary_table' to 'create_summary_list' 39 # - changed 'create_summary_table' to 'create_summary_list'
40 # - changed 'create_output_string' to return a JSON string 40 # - changed 'create_output_string' to return a JSON string
41 # - removed 'load_config_from_file()' because we only use command line
42 # configuration
41 # 43 #
42 44
43 from __future__ import annotations 45 from __future__ import annotations
44 46
45 import argparse 47 import argparse
64 from email.message import Message 66 from email.message import Message
65 from typing import Callable, Dict, Iterator, Optional, Sequence 67 from typing import Callable, Dict, Iterator, Optional, Sequence
66 68
67 69
68 __pkgname__ = "pip-licenses" 70 __pkgname__ = "pip-licenses"
69 __version__ = "4.4.0" 71 __version__ = "5.0.0"
70 __author__ = "raimon"
71 __license__ = "MIT"
72 __summary__ = ( 72 __summary__ = (
73 "Dump the software license list of Python packages installed with pip." 73 "Dump the software license list of Python packages installed with pip."
74 ) 74 )
75 __url__ = "https://github.com/raimon49/pip-licenses"
76 75
77 76
78 FIELD_NAMES = ( 77 FIELD_NAMES = (
79 'Name', 78 'Name',
80 'Version', 79 'Version',
676 return [ 675 return [
677 key.replace("_", "-").lower() for key in enum_cls.__members__.keys() 676 key.replace("_", "-").lower() for key in enum_cls.__members__.keys()
678 ] 677 ]
679 678
680 679
680 def get_value_from_enum(
681 enum_cls: Type[NoValueEnum], value: str
682 ) -> NoValueEnum:
683 return getattr(enum_cls, value_to_enum_key(value))
684
685
681 MAP_DEST_TO_ENUM = { 686 MAP_DEST_TO_ENUM = {
682 'from_': FromArg, 687 'from_': FromArg,
683 'order': OrderArg, 688 'order': OrderArg,
684 } 689 }
685 690
691 namespace: argparse.Namespace, 696 namespace: argparse.Namespace,
692 values: str, 697 values: str,
693 option_string: Optional[str] = None, 698 option_string: Optional[str] = None,
694 ) -> None: 699 ) -> None:
695 enum_cls = MAP_DEST_TO_ENUM[self.dest] 700 enum_cls = MAP_DEST_TO_ENUM[self.dest]
696 values = value_to_enum_key(values) 701 setattr(namespace, self.dest, get_value_from_enum(enum_cls, values))
697 setattr(namespace, self.dest, getattr(enum_cls, values)) 702
698 703
699 704 def create_parser() -> CompatibleArgumentParser:
700 def create_parser():
701 parser = CompatibleArgumentParser( 705 parser = CompatibleArgumentParser(
702 description=__summary__, formatter_class=CustomHelpFormatter 706 description=__summary__, formatter_class=CustomHelpFormatter
703 ) 707 )
704 708
705 common_options = parser.add_argument_group('Common options') 709 common_options = parser.add_argument_group('Common options')

eric ide

mercurial