forked from hoffmann/PyCharm-Python-Templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexport.py
32 lines (25 loc) · 750 Bytes
/
export.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python
"""Export Pycharm templates to html"""
import sys
import lxml.etree
import os.path
import cgi
def export(filename):
tree = lxml.etree.parse(open(filename))
print '<dl>'
for template in tree.findall('.//template'):
print '<dt>%s</dt>' % (cgi.escape(template.get('name')))
print '<dd>%s\n<pre class="prettyprint">%s\n</pre>\n</dd>\n' %
(template.get('description'), template.get('value'))
print '</dl>'
def main(argv=None):
if argv is None:
argv = sys.argv
user_xml_file = os.path.expanduser(
'~/.PyCharm30/config/templates/user.xml'
)
if len(argv) == 2:
user_xml_file = argv[1]
export(user_xml_file)
if __name__ == '__main__':
main()