def get_labview_examples(self): def title_from_filename(filename): return filename.replace('Example ', '').replace('.vi.png', '') def url_fixer(url): return url.replace('.vi.png', '.vi') def display_name_fixer(display_name): return display_name.replace('.vi.png', '.vi') def additional_download_finder(file_path): # if file name is "Example Callback - Event Callback.vi" then # glob for "Example Callback - *" dir_name, filename = os.path.split(file_path) additional_downloads = [] pattern = os.path.join(dir_name, filename.replace('.vi.png', '') + ' - *') for additional_file_path in glob.glob(pattern): additional_downloads.append( os.path.split(additional_file_path)[1]) return additional_downloads return common.make_rst_examples( title_from_filename, self, url_fixer=url_fixer, is_picture=True, additional_download_finder=additional_download_finder, display_name_fixer=display_name_fixer)
def get_matlab_examples(self): def title_from_filename(filename): title = filename.replace('matlab_example_', '').replace('octave_example_', '').replace('.m', '') if filename.startswith('matlab_'): return common.underscore_to_space(title) + ' (MATLAB)' elif filename.startswith('octave_'): return common.underscore_to_space(title) + ' (Octave)' else: raise ValueError('Invalid filename ' + filename) def language_from_filename(filename): if filename.startswith('matlab_'): return 'matlab' elif filename.startswith('octave_'): return 'octave_fixed' else: raise ValueError('Invalid filename ' + filename) return common.make_rst_examples( title_from_filename, self, language_from_filename=language_from_filename)
def get_labview_examples(self): def title_from_filename(filename): return filename.replace('Example ', '').replace('.vi.png', '') def url_fixer(url): return url.replace('.vi.png', '.vi') def display_name_fixer(display_name): return display_name.replace('.vi.png', '.vi') def additional_download_finder(file_path): # if file name is "Example Callback - Event Callback.vi" then # glob for "Example Callback - *" dir_name, filename = os.path.split(file_path) additional_downloads = [] pattern = os.path.join(dir_name, filename.replace('.vi.png', '') + ' - *') for additional_file_path in glob.glob(pattern): additional_downloads.append(os.path.split(additional_file_path)[1]) return additional_downloads return common.make_rst_examples(title_from_filename, self, url_fixer=url_fixer, is_picture=True, additional_download_finder=additional_download_finder, display_name_fixer=display_name_fixer)
def make_examples(): def title_from_file(f): f = f.replace("Example", "") f = f.replace(".java", "") return common.camel_case_to_space(f) return common.make_rst_examples(title_from_file, device, common.path_binding, "java", "Example", ".java", "Java")
def make_examples(): def title_from_file(f): f = f.replace('Example', '') f = f.replace('.cs', '') return common.camel_case_to_space(f) return common.make_rst_examples(title_from_file, device, common.path_binding, 'csharp', 'Example', '.cs', 'CSharp')
def make_examples(): def title_from_file(f): f = f.replace('Example', '') f = f.replace('.php', '') return common.camel_case_to_space(f) return common.make_rst_examples(title_from_file, device, file_path, 'php', 'Example', '.php', 'PHP')
def make_examples(): def title_from_file(f): f = f.replace('Example', '') f = f.replace('.vb', '') return common.camel_case_to_space(f) return common.make_rst_examples(title_from_file, device, common.path_binding, 'vbnet', 'Example', '.vb', 'VBNET')
def get_shell_examples(self): def title_from_filename(filename): filename = filename.replace("example-", "").replace(".sh", "").replace("-", "_") return common.underscore_to_space(filename) def language_from_filename(filename): return "bash" return common.make_rst_examples(title_from_filename, self, language_from_filename=language_from_filename)
def get_mqtt_examples(self): def title_from_filename(filename): filename = filename.replace('example-', '').replace('.txt', '').replace('-', '_') return common.under_to_space(filename).replace('Pwm ', 'PWM ') return common.make_rst_examples(title_from_filename, self, language_from_filename=lambda f: None)
def get_shell_examples(self): def title_from_filename(filename): filename = filename.replace('example-', '').replace('.sh', '').replace('-', '_') return common.underscore_to_space(filename) def language_from_filename(filename): return 'bash' return common.make_rst_examples(title_from_filename, self, language_from_filename=language_from_filename)
def get_tvpl_examples(self): # FIXME def title_from_filename(filename): filename = filename.replace('example_', '').replace('.tvpl', '') return common.under_to_space(filename) def language_from_filename(filename): return 'xml' return common.make_rst_examples(title_from_filename, self, language_from_filename=language_from_filename, add_tvpl_test_link=True)
def make_examples(): def title_from_file(f): f = f.replace('example_', '') f = f.replace('.rb', '') s = '' for l in f.split('_'): s += l[0].upper() + l[1:] + ' ' return s[:-1] return common.make_rst_examples(title_from_file, device, file_path, 'ruby', 'example_', '.rb', 'Ruby')
def make_examples(): def title_from_file(f): f = f.replace('example_', '') f = f.replace('.py', '') s = '' for l in f.split('_'): s += l[0].upper() + l[1:] + ' ' return s[:-1] return common.make_rst_examples(title_from_file, device, common.path_binding, 'python', 'example_', '.py', 'Python')
def get_mathematica_examples(self): def title_from_filename(filename): filename = filename.replace('Example', '').replace('.nb.txt', '') return common.camel_case_to_space(filename) def url_fixer(url): return url.replace('.nb.txt', '.nb') def display_name_fixer(url): return url.replace('.nb.txt', '.nb') return common.make_rst_examples(title_from_filename, self, url_fixer=url_fixer, display_name_fixer=display_name_fixer)
def get_mathematica_examples(self): def title_from_filename(filename): filename = filename.replace('Example', '').replace('.nb.txt', '') return common.camel_to_space(filename) def url_fixer(url): return url.replace('.nb.txt', '.nb') def display_name_fixer(url): return url.replace('.nb.txt', '.nb') return common.make_rst_examples(title_from_filename, self, url_fixer=url_fixer, display_name_fixer=display_name_fixer)
def get_matlab_examples(self): def title_from_filename(filename): title = filename.replace('matlab_example_', '').replace('octave_example_', '').replace('.m', '') if filename.startswith('matlab_'): return common.underscore_to_space(title) + ' (MATLAB)' elif filename.startswith('octave_'): return common.underscore_to_space(title) + ' (Octave)' else: raise ValueError('Invalid filename ' + filename) def language_from_filename(filename): if filename.startswith('matlab_'): return 'matlab' elif filename.startswith('octave_'): return 'octave_fixed' else: raise ValueError('Invalid filename ' + filename) return common.make_rst_examples(title_from_filename, self, language_from_filename=language_from_filename)
def get_javascript_examples(self): def title_from_filename(filename): if filename.endswith('.js'): filename = filename.replace('Example', '').replace('.js', '') return common.underscore_to_space(filename) + ' (Node.js)' elif filename.endswith('.html'): filename = filename.replace('Example', '').replace('.html', '') return common.underscore_to_space(filename) + ' (HTML)' else: raise ValueError('Invalid filename ' + filename) def language_from_filename(filename): if filename.endswith('.js'): return 'javascript' elif filename.endswith('.html'): return 'html' else: raise ValueError('Invalid filename ' + filename) return common.make_rst_examples(title_from_filename, self, language_from_filename=language_from_filename)
def get_javascript_examples(self): def title_from_filename(filename): if filename.endswith('.js'): filename = filename.replace('Example', '').replace('.js', '') return common.camel_to_space(filename) + ' (Node.js)' elif filename.endswith('.html'): filename = filename.replace('Example', '').replace('.html', '') return common.camel_to_space(filename) + ' (HTML)' else: raise common.GeneratorError('Invalid filename ' + filename) def language_from_filename(filename): if filename.endswith('.js'): return 'javascript' elif filename.endswith('.html'): return 'html' else: raise common.GeneratorError('Invalid filename ' + filename) return common.make_rst_examples(title_from_filename, self, language_from_filename=language_from_filename, add_html_test_link=True)
def get_javascript_examples(self): def title_from_filename(filename): if filename.endswith('.js'): filename = filename.replace('Example', '').replace('.js', '') return common.underscore_to_space(filename) + ' (Node.js)' elif filename.endswith('.html'): filename = filename.replace('Example', '').replace('.html', '') return common.underscore_to_space(filename) + ' (HTML)' else: raise ValueError('Invalid filename ' + filename) def language_from_filename(filename): if filename.endswith('.js'): return 'javascript' elif filename.endswith('.html'): return 'html' else: raise ValueError('Invalid filename ' + filename) return common.make_rst_examples( title_from_filename, self, language_from_filename=language_from_filename, add_test_link=True)
def get_perl_examples(self): def title_from_filename(filename): filename = filename.replace('example_', '').replace('.pl', '') return common.under_to_space(filename) return common.make_rst_examples(title_from_filename, self)
def get_mqtt_examples(self): def title_from_filename(filename): filename = filename.replace('example-', '').replace('.txt', '').replace('-','_') return common.under_to_space(filename).replace('Pwm ', 'PWM ') return common.make_rst_examples(title_from_filename, self, language_from_filename=lambda f: None)
def get_perl_examples(self): def title_from_filename(filename): filename = filename.replace("example_", "").replace(".pl", "") return common.underscore_to_space(filename) return common.make_rst_examples(title_from_filename, self)
def get_go_examples(self): def title_from_filename(filename): filename = filename.replace('example_', '').replace('.go', '') return common.underscore_to_space(filename).replace('Pwm ', 'PWM ') return common.make_rst_examples(title_from_filename, self)
def get_delphi_examples(self): def title_from_filename(filename): filename = filename.replace('Example', '').replace('.pas', '') return common.camel_to_space(filename) return common.make_rst_examples(title_from_filename, self)
def get_ruby_examples(self): def title_from_filename(filename): filename = filename.replace('example_', '').replace('.rb', '') return common.underscore_to_space(filename) return common.make_rst_examples(title_from_filename, self)
def get_delphi_examples(self): def title_from_filename(filename): filename = filename.replace("Example", "").replace(".pas", "") return common.camel_case_to_space(filename) return common.make_rst_examples(title_from_filename, self)
def get_csharp_examples(self): def title_from_filename(filename): filename = filename.replace('Example', '').replace('.cs', '') return common.camel_to_space(filename) return common.make_rst_examples(title_from_filename, self)
def get_vbnet_examples(self): def title_from_filename(filename): filename = filename.replace('Example', '').replace('.vb', '') return common.camel_case_to_space(filename) return common.make_rst_examples(title_from_filename, self)
def get_csharp_examples(self): def title_from_filename(filename): filename = filename.replace('Example', '').replace('.cs', '') return common.camel_case_to_space(filename) return common.make_rst_examples(title_from_filename, self)
def get_c_examples(self): def title_from_filename(filename): filename = filename.replace('example_', '').replace('.c', '') return common.under_to_space(filename).replace('Pwm ', 'PWM ') return common.make_rst_examples(title_from_filename, self)