diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..af2633f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +language: python +python: + - "3.3" + +#run tests +#script: python -m unittest diff --git a/source/json-generator.py b/source/json-generator.py new file mode 100644 index 0000000..bae24b2 --- /dev/null +++ b/source/json-generator.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 + +import os +import fnmatch +from json import dumps, load + +def writeJson(data, filename): + try: + jsondata = dumps(data, indent=2, skipkeys=True, sort_keys=True) + fd = open(filename, 'w') + fd.write(jsondata) + fd.close() + except: + print 'ERROR writing', filename + pass + +def getDir(path, ext): + matches = [] + for root, dirnames, filenames in os.walk(path): + for filename in fnmatch.filter(filenames, ext): + matches.append(os.path.join(root, filename)) + return matches + + +result = [] +for file in getDir('../snippets/', '*.sublime-snippet'): + line = open(file) + content = line.read() + trigger = content.split('')[1].split('')[0] + description = content.split('')[1].split('')[0] + + result.append({'trigger':trigger, 'description':description}) + +writeJson(result, "../snippets.json") + diff --git a/tests/test.py b/tests/test.py new file mode 100644 index 0000000..b60c973 --- /dev/null +++ b/tests/test.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +import unittest + +class TestStringMethods(unittest.TestCase): + + def test_upper(self): + self.assertEqual('foo'.upper(), 'FOO') + + def test_isupper(self): + self.assertTrue('FOO'.isupper()) + self.assertFalse('Foo'.isupper()) + + def test_split(self): + s = 'hello world' + self.assertEqual(s.split(), ['hello', 'world']) + # check that s.split fails when the separator is not a string + with self.assertRaises(TypeError): + s.split(2) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/unittest_compat.py b/tests/unittest_compat.py new file mode 100644 index 0000000..e69de29