Skip to content

Commit f31bc1a

Browse files
committed
Fixed #5 add substring matching
1 parent 5ffbcd5 commit f31bc1a

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

STP.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,26 @@
22
from biplist import *
33
import json
44
import os
5+
import re
56

67
class SourceTree:
78

89
homePath=os.path.expanduser('~')
910
filePath= homePath + "/Library/Application Support/SourceTree/browser.plist"
1011

12+
def _camel_case_split(self, identifier):
13+
matches = re.finditer('.+?(?:(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|$)', identifier)
14+
return [m.group(0) for m in matches]
15+
16+
def _splitMatchWords(self, title):
17+
res = []
18+
cam = self._camel_case_split(title)
19+
for m in cam:
20+
ret = re.split('-|_| |',m)
21+
for n in ret:
22+
res.append(n)
23+
return ' '.join(res);
24+
1125
def _getProjects(self):
1226
try:
1327
plist = readPlist(self.filePath)
@@ -29,7 +43,8 @@ def getList(self):
2943
item = {
3044
'title': p[0],
3145
'subtitle': p[1],
32-
'arg': p[1]
46+
'arg': p[1],
47+
'match': self._splitMatchWords(p[0])
3348
}
3449
items.append(item)
3550
result = {'items': items}

screenshot.png

0 Bytes
Loading

0 commit comments

Comments
 (0)