def clear_out_dir(dev, lang): for file in (declension_files + testcases_files): # Копирование результата в `ru.out`: out_file = get_path(dev, lang, file, out=True) ensure_parent_dir(out_file) copy(get_path(dev, lang, file, out=False), out_file) if not compare_dir(dev, lang): print(f'Ошибка: папки `{lang}` не синхронизированы.') return
def download(dev=True): if not compare_dir('lua'): print('Ошибка: папки `lua` не синхронизированы.') return path = get_path('lua') print(f'Скачиваю lua-модули в папку:\n {path}\nМодули:') for file in files: title = get_module_title(file, dev) download_module(title, f'{path}/{file}.lua')
def convert_dir(dev, _from, _to): if not compare_dir(dev, _to): print(f'Ошибка: папки `{_to}` не синхронизированы до конвертации.') return for file in declension_files: # Прямое преобразование: convert_file(dev, file, _from, _to, out=False) # Копирование результата в `ru.out`: in_file = get_path(dev, _to, file, out=False) out_file = get_path(dev, _to, file, out=True) write(out_file, '') # чтобы создать папки, если их нет copy(in_file, out_file) # Обратное преобразование для .out: convert_file(dev, file, _to, _from, out=True) if not compare_dir(dev, _from): print( f'Ошибка: папки `{_from}` не синхронизированы после конвертации.') return
def download_lua(dev, testcases=False): if not compare_dir(dev, 'lua'): print('Ошибка: папки `lua` не синхронизированы.') return path = get_path(dev, 'lua', '', root=True) print(f'Скачиваю lua-модули в папку:\n {path}\nМодули:') files = testcases_files if testcases else declension_files for file in files: title = get_module_title(file, dev) filename = get_path(dev, 'lua', file, '') download_page(title, filename)
def clear_out_dir(lang): py_path = get_path(lang) for module in files: active = module.replace('[.out]', '') out = module.replace('[.out]', '.out') # Копирование результата в `libs.out`: copy(join(py_path, f'{active}.{lang}'), join(py_path, f'{out}.{lang}')) if not compare_dir(lang): print(f'Ошибка: папки `{lang}` не синхронизированы.') return
def convert_dir(_from, _to): if not compare_dir(_to): print(f'Ошибка: папки `{_to}` не синхронизированы.') return py_path = get_path(_to) for module in files: active = module.replace('[.out]', '') out = module.replace('[.out]', '.out') # Прямое преобразование: convert_file(active, _from, _to) # Копирование результата в `libs.out`: copy(join(py_path, f'{active}.{_to}'), join(py_path, f'{out}.{_to}')) # Обратное преобразование для .out: convert_file(out, _to, _from) if not compare_dir(_from): print(f'Ошибка: папки `{_from}` не синхронизированы.') return
def upload_lua(version, desc, dev, testcases=False): if not compare_dir(dev, 'lua'): print('Ошибка: папки `lua` не синхронизированы.') return desc = process_desc(dev, version, desc) print(f'Загружаю lua-модули в ВС:') files = testcases_files if testcases else declension_files for file in files: title = get_module_title(file, dev) print(f'- {title} - ', end='') path = get_path(dev, 'lua', file, out=True) if save_page(title, read_file(dev, path), f'v{version}: {desc}'): print('OK')
def upload(dev, ru_noun_version, inflection_version, desc): if not compare_dir('lua'): print('Ошибка: папки `lua` не синхронизированы.') return desc = process_desc(dev, desc) path = get_path('lua') print(f'Загружаю lua-модули в ВС:') for file in files: title = get_module_title(file, dev) print(f'- {title} - ', end='') file = file.replace('[.out]', '.out') if save_page(title, read_file(dev, f'{path}/{file}.lua'), f'v{ru_noun_version}: {desc}'): print('OK') dev_prefix = 'User:Vitalik/' if dev else '' title = f'Module:{dev_prefix}inflection/tools' path = get_path('lua', noun=False) save_page(title, read_file(dev, f'{path}/tools.lua'), f'v{inflection_version}: {desc}')