Added a very basic fetching utility that fetches TextMate Bundle Snippets from the TextMate site and writes out a file that is compatible with us. Also added a new critical feature/bug that needs fixing: Tabstops in Default Text of Tabstops

This commit is contained in:
Holger Rapp 2009-07-07 09:41:09 +02:00
parent 3ac62a0315
commit 9adaccabf1
2 changed files with 59 additions and 0 deletions

View File

@ -227,6 +227,7 @@ class TabStopTestMultilineExpand_ExceptCorrectResult(_VimTest):
print "expand, jump forward, jump backwards should all be individual"
print "Shell eval snippets"
print "Tabstop in default text of tabstop. Like in Ruby Dir snippet in TextMate"
# functions
# Multiline text pasting

58
utils/get_tm_snippets.py Executable file
View File

@ -0,0 +1,58 @@
#!/usr/bin/env python
# encoding: utf-8
import urllib
import re
from xml.etree import ElementTree
def parse_content(c):
data = ElementTree.fromstring(c)[0]
rv = {}
for k,v in zip(data[::2], data[1::2]):
rv[k.text] = v.text
return rv
def fetch_snippets(name):
base_url = "http://svn.textmate.org/trunk/Bundles/" + name + ".tmbundle/"
snippet_idx = base_url + "Snippets/"
idx_list = urllib.urlopen(snippet_idx).read()
rv = []
for link in re.findall("<li>(.*?)</li>", idx_list):
m = re.match(r'<a\s*href="(.*)"\s*>(.*)</a>', link)
link, name = m.groups()
if name == "..":
continue
name = name.rsplit('.', 1)[0] # remove Extension
print "Fetching data for Snippet '%s'" % name
content = urllib.urlopen(snippet_idx + link).read()
rv.append((name, parse_content(content)))
return rv
def write_snippets(snip_descr, f):
for name, d in snip_descr:
if "tabTrigger" not in d:
continue
f.write('snippet %s "%s"\n' % (d["tabTrigger"], name))
f.write(d["content"] + "\n")
f.write("endsnippet\n\n")
if __name__ == '__main__':
import sys
bundle = sys.argv[1]
rv = fetch_snippets(bundle)
write_snippets(rv, open("tm_" + bundle.lower() + ".snippets","w"))