|
35 | 35 |
|
36 | 36 | import itertools
|
37 | 37 | import sys
|
| 38 | +import inspect |
| 39 | +from types import FunctionType |
38 | 40 |
|
39 | 41 | from fire import completion
|
40 | 42 | from fire import custom_descriptions
|
@@ -68,6 +70,7 @@ def HelpText(component, trace=None, verbose=False):
|
68 | 70 | metadata = decorators.GetMetadata(component)
|
69 | 71 |
|
70 | 72 | # Sections:
|
| 73 | + spec.args=Checker(spec,component) |
71 | 74 | name_section = _NameSection(component, info, trace=trace, verbose=verbose)
|
72 | 75 | synopsis_section = _SynopsisSection(
|
73 | 76 | component, actions_grouped_by_kind, spec, metadata, trace=trace)
|
@@ -95,6 +98,42 @@ def HelpText(component, trace=None, verbose=False):
|
95 | 98 | )
|
96 | 99 |
|
97 | 100 |
|
| 101 | +def Checker(spec,component): |
| 102 | + """ |
| 103 | + desc: |
| 104 | + Checker funcition firstly checks type of component and afterthat |
| 105 | + it extract all parent classes. |
| 106 | + Return: |
| 107 | + case 1: If there is any parent class it will return all_args list. |
| 108 | + case 2: If there is no parent class so it will return only args list. |
| 109 | + """ |
| 110 | + if type(component) is not FunctionType and type(component) is not object: |
| 111 | + try: |
| 112 | + Inherit_classes_list=inspect.getmro(component) |
| 113 | + if len(Inherit_classes_list)>2: |
| 114 | + return ReturnAllArgs(Inherit_classes_list) |
| 115 | + except AttributeError as e: |
| 116 | + pass |
| 117 | + |
| 118 | + return spec.args |
| 119 | + |
| 120 | + |
| 121 | +def ReturnAllArgs(Inherit_classes_list): |
| 122 | + """ |
| 123 | + Inherit_classes_list: It is a list which have collection of parent classes. |
| 124 | + Return: list of all arguments which is retrieved from parent classes. |
| 125 | + """ |
| 126 | + all_args = [] |
| 127 | + if len(Inherit_classes_list)>2: |
| 128 | + for classes in Inherit_classes_list: |
| 129 | + argspec_tuple=inspect.getargspec(classes) |
| 130 | + args_list=argspec_tuple[0] |
| 131 | + for arg in args_list[1:]: |
| 132 | + all_args.append(arg) |
| 133 | + |
| 134 | + return all_args |
| 135 | + |
| 136 | + |
98 | 137 | def _NameSection(component, info, trace=None, verbose=False):
|
99 | 138 | """The "Name" section of the help string."""
|
100 | 139 |
|
|
0 commit comments