def Display(self, args, result): """This method is called to print the result of the Run() method. Args: args: The arguments that command was run with. result: The value returned from the Run() method. """ columns = [] if args.show_log_levels: columns.append(('LEVEL', attrpath.Selector('level'))) if args.show_function_names: columns.append(('NAME', attrpath.Selector('name'))) if args.show_execution_ids: columns.append(('EXECUTION_ID', attrpath.Selector('execution_id'))) if args.show_timestamps: columns.append(('TIME_UTC', attrpath.Selector('time_utc'))) columns.append(('LOG', attrpath.Selector('log'))) console_io.PrintExtendedList(result, columns)
def _Select(path, transform=None): """Get a column fetcher for the given attr path and transform. Args: path: str, The attr path that keys into the resource. transform: func(str)->str, A func that takes something found by the path and maps it to some other strip. Returns: func(obj)->str, A func that takes an object and returns the value for a particular column. """ getter = attrpath.Selector(path) if transform is None: return getter def GetAndTransform(obj): return transform(getter(obj)) return GetAndTransform