Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4041b10

Browse files
committed
remove stream.py dependency
1 parent b5af6ee commit 4041b10

5 files changed

Lines changed: 14 additions & 57 deletions

File tree

‎go.py‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import windows as winutils
77
from datetime import datetime
88
from utils import Query
9-
import stream as sm
109
from PyQt4.QtCore import (
1110
Qt,
1211
QAbstractListModel,
@@ -120,7 +119,7 @@ def sorted_active_runnable(self, query, hwnds):
120119
with QMutexLocker(self.go.mutex):
121120
# update query and collect active ones
122121
self.go._refresh_tasks(hwnds, query)
123-
active_tasks = hwnds>>sm.map(lambdah: self.go.tasks[h]) >>list
122+
active_tasks = [self.go.tasks[h]forhinhwnds]
124123

125124
# sort by last use
126125
if not query:
@@ -136,13 +135,14 @@ def f(task):
136135

137136
def run(self):
138137
model = WindowModel(
139-
self.sorted_active_runnable(self.query, _top_level_windows())\
140-
>> sm.map(lambda t: WindowInfo(
141-
hwnd=t.hwnd,
142-
name=_window_title(t.hwnd),
143-
icon=winutils.get_window_icon(t.hwnd)
144-
))\
145-
>> sm.item[:self.upper_bound]
138+
[
139+
WindowInfo(
140+
hwnd=t.hwnd,
141+
name=_window_title(t.hwnd),
142+
icon=winutils.get_window_icon(t.hwnd)
143+
) for t in
144+
self.sorted_active_runnable(self.query, _top_level_windows())\
145+
][:self.upper_bound]
146146
)
147147
if self.done and not self.stopped:
148148
self.done(model)

‎lit.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
from qt import QT_API, QT_API_PYQT
4545

4646
from common import LitJob
47-
import stream as sm
4847
import os
4948
import re
5049
import win32gui
@@ -190,7 +189,7 @@ def show_window(self):
190189
#QTimer.singleShot(100, lambda: windows.goto(hwnd(self)))
191190

192191
def _install_plugins(self, plugins):
193-
self.plugins = plugins>>sm.map(lambdap: (p.name, p)) >>dict
192+
self.plugins = {p.name: pforpinplugins}
194193
self.default_plugin = plugins[0] if self.plugins else None
195194

196195
def _try_query(self, text):
@@ -354,7 +353,7 @@ def update(self, result):
354353
model = result
355354
else:
356355
model = QStringListModel()
357-
model.setStringList(result>>sm.map(str) >>list)
356+
model.setStringList([str(r) forrinresult])
358357

359358
self.setModel(model)
360359
self.setCompletionPrefix('')

‎run.py‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from utils import Query
77
import win32api
88
from collections import namedtuple
9-
import stream as sm
109
from PyQt4.QtCore import (
1110
QThread,
1211
QMutex,
@@ -98,9 +97,7 @@ def f(arg):
9897
return 0
9998
return arg[1].query.distance_to(arg[1].name.lower())
10099

101-
names = sorted(self.d.items(), key=f)\
102-
>> sm.apply(lambda name, _: name)\
103-
>> sm.item[:self.upper_bound]
100+
names = [name for name, _ in sorted(self.d.items(), key=f)][:self.upper_bound]
104101

105102
if self.done and not self.stopped:
106103
self.done(names)

‎suggest.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
QModelIndex,
2121
QAbstractItemModel
2222
)
23-
import stream as sm
2423

2524

2625
class CenterListView(QListView):
@@ -221,7 +220,7 @@ def update(self, content):
221220
model = content
222221
else:
223222
model = QStringListModel()
224-
model.setStringList(content>>sm.map(str) >>list)
223+
model.setStringList([str(c) forcincontent])
225224

226225
self.model = model
227226

‎utils.py‎

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,6 @@
22
# -*- coding: utf-8 -*-
33

44

5-
import stream as sm
6-
7-
8-
def damerau_levenshtein_distance(
9-
s1,
10-
s2,
11-
deletion_cost=1,
12-
insertion_cost=1,
13-
substitution_cost=1,
14-
transposition_cost=1
15-
):
16-
d = {}
17-
lenstr1 = len(s1)
18-
lenstr2 = len(s2)
19-
for i in range(-1,lenstr1+1):
20-
d[(i,-1)] = (i + 1) * deletion_cost
21-
for j in range(-1,lenstr2+1):
22-
d[(-1,j)] = min(j + 1, 1) * insertion_cost
23-
24-
for i in range(lenstr1):
25-
best_before_insertion_cost = d[(i,-1)]
26-
for j in range(lenstr2):
27-
best_before_insertion_cost = min(best_before_insertion_cost, d[(i,j-1)])
28-
if s1[i] == s2[j]:
29-
cost = 0
30-
else:
31-
cost = 1
32-
d[(i,j)] = min(
33-
d[(i-1,j)] + deletion_cost, # deletion
34-
best_before_insertion_cost + insertion_cost, # insertion
35-
d[(i-1,j-1)] + cost * substitution_cost, # substitution
36-
)
37-
if i and j and s1[i]==s2[j-1] and s1[i-1] == s2[j]:
38-
d[(i,j)] = min (d[(i,j)], d[i-2,j-2] + cost * transposition_cost) # transposition
39-
40-
return d[lenstr1-1,lenstr2-1]
41-
42-
435
def levenshtein(
446
s1,
457
s2,
@@ -55,7 +17,7 @@ def levenshtein(
5517
if not a:
5618
a.append([i * insertion_cost for i in range(len(s2) + 1)])
5719

58-
for i, c1 in enumerate(s1)>>sm.drop(len(a) - 1):
20+
for i, c1 in list(enumerate(s1))[len(a) - 1:]:
5921
previous_row = i
6022
current_row = i + 1
6123
a.append([0 for i in range(len(s2) + 1)])

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /