예제 #1
0
def install_lang(lang):
    """Install a single lang given by the argument."""
    lang_url = API_URL + lang.remote_path + '?format=TEXT'
    if not os.path.isdir(spell.dictionary_dir()):
        msg = '{} does not exist, creating the directory'
        print(msg.format(spell.dictionary_dir()))
        os.makedirs(spell.dictionary_dir())
    print('Downloading {}'.format(lang_url))
    dest = os.path.join(spell.dictionary_dir(), lang.remote_path)
    download_dictionary(lang_url, dest)
    print('Done.')
예제 #2
0
def install_lang(lang):
    """Install a single lang given by the argument."""
    lang_url = API_URL + lang.remote_filename + '?format=TEXT'
    if not os.path.isdir(spell.dictionary_dir()):
        msg = '{} does not exist, creating the directory'
        print(msg.format(spell.dictionary_dir()))
        os.makedirs(spell.dictionary_dir())
    print('Downloading {}'.format(lang_url))
    dest = os.path.join(spell.dictionary_dir(), lang.remote_filename)
    download_dictionary(lang_url, dest)
    print('Installed to {}.'.format(dest))
예제 #3
0
def install_lang(lang):
    """Install a single lang given by the argument."""
    print('Installing {}: {}'.format(lang.code, lang.name))
    lang_url = API_URL + lang.file_path + '?format=TEXT'
    if not os.path.isdir(spell.dictionary_dir()):
        warn_msg = '{} does not exist, creating the directory'
        print(warn_msg.format(spell.dictionary_dir()))
        os.makedirs(spell.dictionary_dir())
    print('Downloading {}'.format(lang_url))
    dest = os.path.join(spell.dictionary_dir(), lang.file_path)
    download_dictionary(lang_url, dest)
    print('Done.')
예제 #4
0
def remove_old(languages):
    """Remove old versions of languages."""
    installed = [lang for lang in languages if lang.local_version is not None]
    for lang in installed:
        local_files = spell.local_files(lang.code)
        for old_file in local_files[1:]:
            os.remove(os.path.join(spell.dictionary_dir(), old_file))
예제 #5
0
def test_dictionary_dir(monkeypatch, qt_version, old, subdir):
    monkeypatch.setattr(qtutils, 'qVersion', lambda: qt_version)
    monkeypatch.setattr(QLibraryInfo, 'location', lambda _: 'global_datapath')
    monkeypatch.setattr(standarddir, 'data', lambda: 'user_datapath')

    expected = os.path.join(subdir, 'qtwebengine_dictionaries')
    assert spell.dictionary_dir(old=old) == expected
예제 #6
0
def remove_old(languages):
    """Remove old versions of languages."""
    installed = [lang for lang in languages if lang.local_version is not None]
    for lang in installed:
        local_files = spell.local_files(lang.code)
        for old_file in local_files[1:]:
            os.remove(os.path.join(spell.dictionary_dir(), old_file))
예제 #7
0
def test_dictionary_dir(monkeypatch, qt_version, old, subdir):
    monkeypatch.setattr(qtutils, 'qVersion', lambda: qt_version)
    monkeypatch.setattr(QLibraryInfo, 'location', lambda _: 'global_datapath')
    monkeypatch.setattr(standarddir, 'data', lambda: 'user_datapath')

    expected = os.path.join(subdir, 'qtwebengine_dictionaries')
    assert spell.dictionary_dir(old=old) == expected
예제 #8
0
def test_dictionary_dir(monkeypatch):
    monkeypatch.setattr(QLibraryInfo, 'location', lambda _: 'datapath')
    assert spell.dictionary_dir() == os.path.join('datapath',
                                                  'qtwebengine_dictionaries')