From 60dccf6e6fa74c1f2b5312b5fcd2fc159db82c67 Mon Sep 17 00:00:00 2001 From: Hemerson Vianna Date: Sun, 24 Jan 2016 22:31:05 -0200 Subject: [PATCH 1/3] add: travis --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..81fc333 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +language: python +python: + - "3.3" + +#run tests +script: python -m unittest From 1845247ac7658a1714a84f6d328f3cf20148fddc Mon Sep 17 00:00:00 2001 From: Hemerson Vianna Date: Sun, 24 Jan 2016 22:31:56 -0200 Subject: [PATCH 2/3] add: initial test files --- tests/test.py | 22 ++++++++++++++++++++++ tests/unittest_compat.py | 0 2 files changed, 22 insertions(+) create mode 100644 tests/test.py create mode 100644 tests/unittest_compat.py 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 From 8ec6b8d000bd25b17a252c559f7e0ff60eaed9bc Mon Sep 17 00:00:00 2001 From: Hemerson Vianna Date: Mon, 25 Jan 2016 09:51:27 -0200 Subject: [PATCH 3/3] add: simple json generator in python --- .travis.yml | 2 +- source/json-generator.py | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 source/json-generator.py diff --git a/.travis.yml b/.travis.yml index 81fc333..af2633f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,4 +3,4 @@ python: - "3.3" #run tests -script: python -m unittest +#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") +