Skip to content

Commit

Permalink
enhancement of issue295
Browse files Browse the repository at this point in the history
  • Loading branch information
Rohan-Salwan committed Nov 26, 2021
1 parent ed44d8b commit 18a0a8f
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions fire/helptext.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

import itertools
import sys
import inspect
from types import FunctionType

from fire import completion
from fire import custom_descriptions
Expand Down Expand Up @@ -68,6 +70,7 @@ def HelpText(component, trace=None, verbose=False):
metadata = decorators.GetMetadata(component)

# Sections:
spec.args=Checker(spec,component)
name_section = _NameSection(component, info, trace=trace, verbose=verbose)
synopsis_section = _SynopsisSection(
component, actions_grouped_by_kind, spec, metadata, trace=trace)
Expand Down Expand Up @@ -95,6 +98,42 @@ def HelpText(component, trace=None, verbose=False):
)


def Checker(spec,component):
"""
desc:
Checker funcition firstly checks type of component and afterthat
it extract all parent classes.
Return:
case 1: If there is any parent class it will return all_args list.
case 2: If there is no parent class so it will return only args list.
"""
if type(component) is not FunctionType and type(component) is not object:
try:
Inherit_classes_list=inspect.getmro(component)
if len(Inherit_classes_list)>2:
return ReturnAllArgs(Inherit_classes_list)
except AttributeError as e:
pass

return spec.args


def ReturnAllArgs(Inherit_classes_list):
"""
Inherit_classes_list: It is a list which have collection of parent classes.
Return: list of all arguments which is retrieved from parent classes.
"""
all_args = []
if len(Inherit_classes_list)>2:
for classes in Inherit_classes_list:
argspec_tuple=inspect.getargspec(classes)
args_list=argspec_tuple[0]
for arg in args_list[1:]:
all_args.append(arg)

return all_args


def _NameSection(component, info, trace=None, verbose=False):
"""The "Name" section of the help string."""

Expand Down

0 comments on commit 18a0a8f

Please sign in to comment.