Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F12297735
jetbrains.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
jetbrains.py
View Options
# -------------------------------------------------------------
# Merge dictionaries :: Output :: JetBrains XML format
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# Description: Find application-level dictionaries
# from JetBrains IDEs
# License: BSD-2-Clause
# -------------------------------------------------------------
from
io
import
StringIO
from
sys
import
version_info
from
xml.etree
import
ElementTree
def
get_xml_tree
(
words
):
root
=
ElementTree
.
Element
(
"application"
)
component
=
ElementTree
.
SubElement
(
root
,
"component"
,
attrib
=
{
"name"
:
"CachedDictionaryState"
,
},
)
words_element
=
ElementTree
.
SubElement
(
component
,
"words"
)
for
word
in
words
:
word_element
=
ElementTree
.
SubElement
(
words_element
,
"w"
)
word_element
.
text
=
word
return
ElementTree
.
ElementTree
(
root
)
def
dump
(
words
):
root
=
get_xml_tree
(
words
)
if
version_info
>=
(
3
,
9
):
ElementTree
.
indent
(
root
)
output
=
StringIO
()
root
.
write
(
output
,
encoding
=
"unicode"
)
contents
=
output
.
getvalue
()
output
.
close
()
return
contents
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Wed, Oct 22, 12:59 (1 d, 12 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3090411
Default Alt Text
jetbrains.py (1 KB)
Attached To
Mode
rMD Merge dev dictionaries
Attached
Detach File
Event Timeline
Log In to Comment