Implementing help function
@@ -18,6 +18,7 @@ import importlib
import glob
import pandas
import code
+import textwrap
from importlib.machinery import SourceFileLoader
@@ -150,8 +151,37 @@ class Chip:
'''Prints help of a parameter, if not arguments are specified
then all help is printed
'''
- pass
+ self.logger.debug('Fetching help for %s', args)
+
+
+ #Fetch Values
+ description = self.search(self.cfg, *args, mode='get', field='short_help')
+ param = self.search(self.cfg, *args, mode='get', field='param_help')
+ helpstr = self.search(self.cfg, *args, mode='get', field='help')
+ example = self.search(self.cfg, *args, mode='get', field='example')
+
+ #Removing multiple spaces and newlines
+ helpstr = helpstr.rstrip()
+ print(helpstr)
+ helpstr = helpstr.replace("\n","")
+ helpstr = ' '.join(helpstr.split())
+ print("string")
+ print(helpstr)
+ #Wrap text
+ para = textwrap.TextWrapper(width=60)
+ para_list = para.wrap(text=helpstr)
+
+ #Print
+ print("-"*80,end='')
+ print("\nDescription: ", description.lstrip(), sep = '')
+ print("\nParameter: ", param.lstrip(), sep = '')
+ print("\nExamples: ", example[0].lstrip(), sep = '',end='')
+ print("\n ", example[1].lstrip(), sep = '')
+ print("\nHelp: ", para_list[0].lstrip(), sep = '')
+ for line in para_list[1:]:
+ print(" "*13,line.lstrip())
+ print("-"*80)
###################################
def get(self, *args):
'''Gets value in the Chip configuration dictionary
@@ -199,11 +229,9 @@ class Chip:
self.logger.debug('Adding config dictionary value: %s', args)
all_args = list(args)
- param = all_args[0]
# Convert val to list if not a list
if type(all_args[-1]) != list:
-
all_args[-1] = [str(all_args[-1])]
return self.search(self.cfg, *all_args, mode='add')
@@ -215,7 +243,6 @@ class Chip:
self.logger.debug('Setting config dictionary value: %s', args)
all_args = list(args)
- param = all_args[0]
# Convert val to list if not a list
if type(all_args[-1]) != list:
