def print_class(name, f): class_dict = CLASSES[name] print('\n', file=f) object_name = class_dict['object_name'] base_type = class_dict['base_type'] # This is for backwards compat (e.g., Trace) and future changes. if object_name is None: print('class {}({}):'.format(name, base_type.__name__), file=f) print(' pass', file=f) return doc = graph_objs_tools.get_help(object_name) if object_name in ARRAYS: base_name = 'PlotlyList' else: base_name = 'PlotlyDict' print('class {}({}):'.format(name, base_name), file=f) doc_lines = doc.splitlines() print(' """', file=f) for doc_line in doc_lines: print(' ' + doc_line, file=f) print('\n """', file=f) print(" _name = '{}'".format(object_name), file=f) if name == 'Figure': print_figure_patch(f) elif name == 'Data': print_data_patch(f)
def _add_classes_to_globals(globals): """ Create and add all the Graph Objects to this module for export. :param (dict) globals: The globals() dict from this module. """ for class_name, class_dict in graph_reference.CLASSES.items(): object_name = class_dict['object_name'] base_type = class_dict['base_type'] # This is for backwards compat (e.g., Trace) and future changes. if object_name is None: globals[class_name] = base_type continue doc = graph_objs_tools.get_help(object_name) if object_name in graph_reference.ARRAYS: class_bases = (PlotlyList, ) else: class_bases = (PlotlyDict, ) class_dict = { '__doc__': doc, '__name__': class_name, '_name': object_name } cls = type(str(class_name), class_bases, class_dict) globals[class_name] = cls
def _add_classes_to_globals(globals): """ Create and add all the Graph Objects to this module for export. :param (dict) globals: The globals() dict from this module. """ for class_name, class_dict in graph_reference.CLASSES.items(): object_name = class_dict['object_name'] base_type = class_dict['base_type'] # This is for backwards compat (e.g., Trace) and future changes. if object_name is None: globals[class_name] = base_type continue doc = graph_objs_tools.get_help(object_name) if object_name in graph_reference.ARRAYS: class_bases = (PlotlyList, ) else: class_bases = (PlotlyDict, ) class_dict = {'__doc__': doc, '__name__': class_name, '_name': object_name} cls = type(str(class_name), class_bases, class_dict) globals[class_name] = cls
def print_class(name, f): class_dict = CLASSES[name] print('\n', file=f) object_name = class_dict['object_name'] base_type = class_dict['base_type'] # This is for backwards compat (e.g., Trace) and future changes. if object_name is None: print('class {}({}):'.format(name, base_type.__name__), file=f) print(' pass', file=f) return doc = graph_objs_tools.get_help(object_name) if object_name in ARRAYS: base_name = 'PlotlyList' else: base_name = 'PlotlyDict' print('class {}({}):'.format(name, base_name), file=f) doc_lines = doc.splitlines() print(' """', file=f) for doc_line in doc_lines: print(' ' + doc_line, file=f) print('\n """', file=f) print(" _name = '{}'".format(object_name), file=f) if name == 'Figure': print_figure_patch(f) elif name == 'Data': print_data_patch(f) elif name == 'Frames': print_frames_patch(f)
def help(self, return_help=False): """ Print a help string for this object. :param (bool) return_help: Return help string instead of prining? :return: (None|str) Optionally can return help string. """ object_name = self._name path = self._get_path() parent_object_names = self._get_parent_object_names() help_string = graph_objs_tools.get_help(object_name, path, parent_object_names) if return_help: return help_string print(help_string)
def test_get_help_does_not_raise(self): msg = None try: for object_name in gr.OBJECTS: msg = object_name got.get_help(object_name) for object_name in gr.ARRAYS: msg = object_name got.get_help(object_name) for object_name in gr.OBJECTS: attributes = gr.get_valid_attributes(object_name) for attribute in attributes: msg = (object_name, attribute) got.get_help(object_name, attribute=attribute) fake_attribute = 'fake attribute' msg = (object_name, fake_attribute) got.get_help(object_name, attribute=fake_attribute) except: self.fail(msg=msg)
def help(self, attribute=None, return_help=False): """ Print help string for this object or an attribute of this object. :param (str) attribute: A valid attribute string for this object. :param (bool) return_help: Return help_string instead of printing it? :return: (None|str) """ if not attribute: return super(PlotlyDict, self).help(return_help=return_help) object_name = self._name path = self._get_path() parent_object_names = self._get_parent_object_names() help_string = graph_objs_tools.get_help(object_name, path, parent_object_names, attribute) if return_help: return help_string print(help_string)