def analyze_and_save_all_endpoints(endpoints=endpoint_list, file_path=None, file_name='analysis.json', pause=1): if not file_path: file_path = get_file_path(directory_name='endpoint_analysis') endpoints_information = load_endpoint_file(file_name=file_name, file_path=file_path) for endpoint in endpoints: attempts = 0 while attempts < 5: attempts += 1 try: if endpoint in endpoints_information and endpoints_information[ endpoint]['status'] in ['success', 'deprecated']: print("skipping", endpoints_information[endpoint]['status'], endpoint) continue endpoint_analysis = analyze_endpoint(endpoint=endpoint, pause=pause) endpoints_information[endpoint] = endpoint_analysis time.sleep(pause) contents = json.dumps(endpoints_information, sort_keys=True, indent=4) save_file(file_path=file_path, file_name=file_name, contents=contents) print(endpoint_analysis['status'], endpoint) break except: pass
def generate_all_endpoint_documentation(directory='endpoint_documentation'): endpoints_information = load_endpoint_file() for endpoint in endpoint_list: if endpoints_information[endpoint]['status'] != 'success': continue file_path = get_file_path(directory) file_name = '{}.md'.format(endpoint.lower()) contents = get_endpoint_documentation(endpoint=endpoint, endpoints_information=endpoints_information) save_file(file_path=file_path, file_name=file_name, contents=contents)
def load_endpoint_file(file_path=None, file_name='analysis.json'): if not file_path: file_path = get_file_path(directory_name='endpoint_analysis') try: endpoints_information = json.loads(load_file(file_path=file_path, file_name=file_name)) except FileNotFoundError: endpoints_information = {} except ValueError: raise Exception('Endpoint file is not in valid a JSON format.') return endpoints_information
def generate_parameter_documentation_file(directory='parameter_documentation', file_name='parameters.md'): contents = get_parameter_documentation_text() file_path = get_file_path(directory) save_file(file_path=file_path, file_name=file_name, contents=contents)