mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
fix incorrectly relative paths
Some dictionaries apparently put the dic and aff file in a sub-directory dictionaries and incorrectly make paths relative to that directory instead of the root, for example: https://github.com/LibreOffice/dictionaries/tree/master/ca
This commit is contained in:
parent
7897c92a3a
commit
9551f021ec
@ -158,8 +158,16 @@ def import_from_oxt(source_path, name, dest_dir=None, prefix='dic-'):
|
|||||||
def import_from_online(directory, name, dest_dir=None, prefix='dic-'):
|
def import_from_online(directory, name, dest_dir=None, prefix='dic-'):
|
||||||
br = browser(timeout=30)
|
br = browser(timeout=30)
|
||||||
def read_file(key):
|
def read_file(key):
|
||||||
rp = br.open('/'.join((ONLINE_DICTIONARY_BASE_URL, directory, key)))
|
try:
|
||||||
return rp.read()
|
rp = br.open('/'.join((ONLINE_DICTIONARY_BASE_URL, directory, key)))
|
||||||
|
return rp.read()
|
||||||
|
except:
|
||||||
|
# Some dictionaries apparently put the dic and aff file in a
|
||||||
|
# sub-directory dictionaries and incorrectly make paths relative
|
||||||
|
# to that directory instead of the root, for example:
|
||||||
|
# https://github.com/LibreOffice/dictionaries/tree/master/ca
|
||||||
|
rp = br.open('/'.join((ONLINE_DICTIONARY_BASE_URL, directory, 'dictionaries', key)))
|
||||||
|
return rp.read()
|
||||||
|
|
||||||
return _import_from_virtual_directory(read_file, name, dest_dir=dest_dir, prefix=prefix)
|
return _import_from_virtual_directory(read_file, name, dest_dir=dest_dir, prefix=prefix)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user