Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F12298106
hunspell.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
hunspell.py
View Options
# -------------------------------------------------------------
# Merge dictionaries :: Sources :: Hunspell
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# Description: Find Hunspell personal dictionaries
# License: BSD-2-Clause
# -------------------------------------------------------------
import
os
def
get_hunspell_environment_variables
():
return
[
"DICTIONARY"
,
"LC_ALL"
,
"LC_MESSAGES"
,
"LANG"
,
]
def
resolve_personal_dictionary_paths_from_environment
():
names
=
{
"default"
}
for
variable
in
get_hunspell_environment_variables
():
if
variable
in
os
.
environ
:
names
.
add
(
os
.
environ
[
variable
])
dictionary_paths
=
[
os
.
path
.
join
(
os
.
environ
[
"HOME"
],
f
".hunspell_{name}"
)
for
name
in
names
]
if
"WORDLIST"
in
os
.
environ
:
dictionary_paths
.
append
(
os
.
environ
[
"WORDLIST"
])
return
dictionary_paths
def
find_personal_dictionaries
():
return
[
file
for
file
in
resolve_personal_dictionary_paths_from_environment
()
if
os
.
path
.
exists
(
file
)
]
def
extract_words
(
dictionary_path
):
return
[
word
.
strip
()
for
word
in
open
(
dictionary_path
)]
def
extract_words_from_all_dictionaries
():
return
{
word
for
dictionary_path
in
find_personal_dictionaries
()
for
word
in
extract_words
(
dictionary_path
)
}
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Wed, Oct 22, 14:02 (15 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3089892
Default Alt Text
hunspell.py (1 KB)
Attached To
Mode
rMD Merge dev dictionaries
Attached
Detach File
Event Timeline
Log In to Comment