Best Python code snippet using toolium_python
poeditor.py
Source:poeditor.py
...63 """64 if context:65 logger.warning('Deprecated context parameter has been sent to download_poeditor_texts method. Please, configure'66 ' dataset global variables instead of passing context to download_poeditor_texts.')67 project_info = get_poeditor_project_info_by_name()68 language_codes = get_poeditor_language_codes(project_info)69 language = get_valid_lang(language_codes)70 poeditor_terms = export_poeditor_project(project_info, language, file_type)71 save_downloaded_file(poeditor_terms)72 # Save terms in dataset to be used in [POE:] map_param replacements73 dataset.poeditor_terms = poeditor_terms74 if context:75 # Save terms in context for backwards compatibility76 context.poeditor_export = dataset.poeditor_terms77def get_poeditor_project_info_by_name(project_name=None):78 """79 Get POEditor project info from project name from config or parameter80 :param project_name: POEditor project name81 :return: project info82 """83 projects = get_poeditor_projects()84 project_name = project_name if project_name else map_param('[CONF:poeditor.project_name]')85 projects_by_name = [project for project in projects if project['name'] == project_name]86 assert len(projects_by_name) == 1, "ERROR: Project name %s not found, available projects: %s" % \87 (project_name, [project['name'] for project in projects])88 return projects_by_name[0]89def get_poeditor_language_codes(project_info):90 """91 Get language codes available for a given project ID92 :param project_info: project info93 :return: project language codes94 """95 params = {"api_token": get_poeditor_api_token(),96 "id": project_info['id']}97 r = send_poeditor_request(ENDPOINT_POEDITOR_LIST_LANGUAGES, "POST", params, 200)98 response_data = r.json()99 assert_poeditor_response_code(response_data, "200")100 language_codes = [lang['code'] for lang in response_data['result']['languages']]101 assert not len(language_codes) == 0, "ERROR: Not languages found in POEditor"102 logger.info('POEditor languages in "%s" project: %s %s' % (project_info['name'], len(language_codes),103 language_codes))104 return language_codes105def search_terms_with_string(context=None, lang=None):106 """107 Saves POEditor terms for a given existing language in that project108 :param context: behave context (deprecated)109 :param lang: a valid language existing in that POEditor project110 :return: N/A (saves it to context.poeditor_terms)111 """112 if context:113 logger.warning('Deprecated context parameter has been sent to search_terms_with_string method. Please, '114 'configure dataset global variables instead of passing context to search_terms_with_string.')115 project_info = get_poeditor_project_info_by_name()116 language_codes = get_poeditor_language_codes(project_info)117 language = get_valid_lang(language_codes, lang)118 dataset.poeditor_terms = get_all_terms(project_info, language)119 if context:120 # Save terms in context for backwards compatibility121 context.poeditor_terms = dataset.poeditor_terms122def export_poeditor_project(project_info, lang, file_type):123 """124 Export all texts in project to a given file type125 :param project_info: project info126 :param lang: language configured in POEditor project that will be exported127 :param file_type: There are more available formats to download but only one is supported now: json128 :return: poeditor terms129 """...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!