How to use get_locale_list method in SeleniumBase

Best Python code snippet using SeleniumBase

mergelocales.py

Source:mergelocales.py Github

copy

Full Screen

...4import subprocess5DIR1 = sys.argv[1]6DIR2 = sys.argv[2]7DEST_DIR = sys.argv[3]8def get_locale_list(path):9 """return names of directories within a locale dir"""10 items = os.listdir(path)11 result = list()12 for item in items:13 if os.path.isdir(os.path.join(path, item)):14 result.append(item)15 return result16def copy_locale_from(localeno, name = None):17 """copy entire locale without merging"""18 if localeno == 1:19 src = os.path.join(DIR1, name)20 elif localeno == 2:21 src = os.path.join(DIR2, name)22 shutil.copytree(src, os.path.join(DEST_DIR, name))23def merge_locales(name):24 """runs msgcat command on specified files25 and a locale name in DIR1 and DIR2"""26 run_msgcat(name, 'django.po')27 run_msgcat(name, 'djangojs.po')28def run_msgcat(locale_name, file_name):29 """run msgcat in locale on file name"""30 file_path = os.path.join(locale_name, 'LC_MESSAGES', file_name)31 dest_file = os.path.join(DEST_DIR, file_path)32 dest_dir = os.path.dirname(dest_file)33 if not os.path.exists(dest_dir):34 os.makedirs(os.path.dirname(dest_file))35 subprocess.call((36 'msgcat',37 os.path.join(DIR1, file_path),38 os.path.join(DIR2, file_path),39 '-o',40 dest_file41 ))42LOCALE_LIST1 = get_locale_list(DIR1)43LOCALE_LIST2 = get_locale_list(DIR2)44for locale in LOCALE_LIST1:45 print locale46 if locale not in LOCALE_LIST2:47 copy_locale_from(1, name = locale)48 else:49 merge_locales(locale)50 LOCALE_LIST2.remove(locale)51for locale in LOCALE_LIST2:52 print locale...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run SeleniumBase automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful