Skip to content

Commit bc970c3

Browse files
committed
-
1 parent 0664668 commit bc970c3

File tree

6 files changed

+54
-8
lines changed

6 files changed

+54
-8
lines changed

.coveragerc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ source =
66
[report]
77
# Gotta ignore errors because I create temporary code files:
88
ignore_errors = True
9+
10+
omit =
11+
*third_party*
12+
*forked_inspect*
13+
*python26_site*
914

1015
[html]
1116
directory = .coverage_html_report

python_toolbox/nifty_collections/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@
88
from .weak_key_default_dict import WeakKeyDefaultDict
99
from .weak_key_identity_dict import WeakKeyIdentityDict
1010
from .counter import Counter
11-
from .lazy_tuple import LazyTuple
11+
from .lazy_tuple import LazyTuple
12+
13+
from .emitting_ordered_set import EmittingOrderedSet
14+
from .emitting_weak_key_default_dict import EmittingWeakKeyDefaultDict

python_toolbox/read_write_lock/read_write_lock.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@
1515

1616

1717
class ContextManager(context_managers.ContextManager):
18+
1819
def __init__(self, lock, acquire_func):
1920
self.lock = lock
2021
self.acquire_func = acquire_func
22+
2123
def __enter__(self):
2224
self.acquire_func()
25+
return self.lock
26+
2327
def __exit__(self, exc_type, exc_value, exc_traceback):
2428
self.lock.release()
2529

@@ -35,10 +39,10 @@ class ReadWriteLock(original_read_write_lock.ReadWriteLock):
3539
3640
Usage:
3741
38-
lock = ReadWriteLock()
39-
with lock.read:
42+
read_write_lock = ReadWriteLock()
43+
with read_write_lock.read:
4044
pass # perform read operations here
41-
with lock.write:
45+
with read_write_lock.write:
4246
pass # perform write operations here
4347
4448
'''

python_toolbox/wx_tools/generic_bitmaps.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
is_win = (wx.Platform == '__WXMSW__')
1414

1515

16-
if is_win:
17-
import win32api
18-
19-
2016
@caching.cache()
2117
def _get_icon_bitmap_from_shell32_dll(index_number, size):
2218
assert isinstance(index_number, int)
19+
assert is_win
20+
21+
import win32api
22+
2323
width, height = size
2424
shell32_dll = win32api.GetModuleFileName(
2525
win32api.GetModuleHandle('shell32.dll')

test_python_toolbox/test_read_write_lock/__init__.py

Whitespace-only changes.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from python_toolbox.read_write_lock import ReadWriteLock
2+
3+
4+
def test():
5+
''' '''
6+
read_write_lock = ReadWriteLock()
7+
with read_write_lock.read:
8+
pass
9+
with read_write_lock.write:
10+
pass
11+
with read_write_lock.read as enter_return_value:
12+
assert enter_return_value is read_write_lock
13+
14+
with read_write_lock.read:
15+
with read_write_lock.read:
16+
with read_write_lock.read:
17+
with read_write_lock.read:
18+
with read_write_lock.write:
19+
with read_write_lock.write:
20+
with read_write_lock.write:
21+
with read_write_lock.write:
22+
pass
23+
24+
with read_write_lock.write:
25+
with read_write_lock.write:
26+
with read_write_lock.write:
27+
with read_write_lock.write:
28+
with read_write_lock.read:
29+
with read_write_lock.read:
30+
with read_write_lock.read:
31+
with read_write_lock.read:
32+
pass
33+
34+

0 commit comments

Comments
 (0)