Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3768107
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/mergedictionaries/sources/jetbrains.py b/src/mergedictionaries/sources/jetbrains.py
index 7f148aa..efd1a1c 100644
--- a/src/mergedictionaries/sources/jetbrains.py
+++ b/src/mergedictionaries/sources/jetbrains.py
@@ -1,57 +1,65 @@
# -------------------------------------------------------------
# Merge dictionaries :: Sources :: JetBrains IDEs
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# Description: Find application-level dictionaries
# from JetBrains IDEs
# License: BSD-2-Clause
# -------------------------------------------------------------
import os
from xml.etree import ElementTree
DICTIONARY_FILENAMES = ["cachedDictionary.xml", "spellchecker-dictionary.xml"]
def get_configuration_path():
- """Find JetBrains configuration folder for Windows and UNIX systems."""
+ """Find JetBrains configuration folder for Windows, macOS and other UNIX systems."""
try:
return os.environ["APPDATA"] + "/JetBrains"
except KeyError:
- return os.environ["HOME"] + "/.config/JetBrains"
+ candidates = [
+ os.environ["HOME"] + "/Library/Application Support/JetBrains",
+ os.environ["HOME"] + "/.config/JetBrains",
+ ]
+ for candidate in candidates:
+ if os.path.exists(candidate):
+ break
+
+ return candidate
def find_application_level_dictionaries():
# We're looking for paths like:
# ~/.config/JetBrains/PyCharm2021.3/options/cachedDictionary.xml
base_path = get_configuration_path()
if not os.path.exists(base_path):
# No JetBrains IDE configuration folder detected
return []
return [
candidate
for candidate in [
os.path.join(base_path, entry.name, "options", filename)
for filename in DICTIONARY_FILENAMES
for entry in os.scandir(base_path)
if entry.is_dir()
]
if os.path.exists(candidate)
]
def extract_words(dictionary_path):
tree = ElementTree.parse(dictionary_path)
return [word.text for word in tree.getroot()[0][0]]
def extract_words_from_all_dictionaries():
return {
word
for dictionary_path in find_application_level_dictionaries()
for word in extract_words(dictionary_path)
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Mon, Nov 25, 06:30 (1 d, 10 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2256379
Default Alt Text
(2 KB)
Attached To
Mode
rMD Merge dev dictionaries
Attached
Detach File
Event Timeline
Log In to Comment