File tree Expand file tree Collapse file tree 3 files changed +13
-11
lines changed
src/frequenz/channels/util Expand file tree Collapse file tree 3 files changed +13
-11
lines changed Original file line number Diff line number Diff line change 4343
4444* The class ` BidirectionalHandle ` was moved to ` Bidirectional.Handle ` .
4545
46+ * The class ` EventType ` was moved to ` FileWatcher.EventType ` .
47+
4648## New Features
4749
4850<!-- Here goes the main new features and examples or instructions on how to use them -->
Original file line number Diff line number Diff line change 1313from .._base_classes import ChannelClosedError , Receiver
1414
1515
16- class EventType (Enum ):
17- """Available types of changes to watch for."""
18-
19- CREATE = Change .added
20- MODIFY = Change .modified
21- DELETE = Change .deleted
22-
23-
2416class FileWatcher (Receiver [pathlib .Path ]):
2517 """A channel receiver that watches for file events."""
2618
19+ class EventType (Enum ):
20+ """Available types of changes to watch for."""
21+
22+ CREATE = Change .added
23+ MODIFY = Change .modified
24+ DELETE = Change .deleted
25+
2726 def __init__ (
2827 self ,
2928 paths : List [Union [pathlib .Path , str ]],
@@ -37,7 +36,7 @@ def __init__(
3736 all event types.
3837 """
3938 if event_types is None :
40- event_types = { EventType . CREATE , EventType . MODIFY , EventType . DELETE }
39+ event_types = set ( FileWatcher . EventType ) # all types
4140
4241 self .event_types = event_types
4342 self ._stop_event = asyncio .Event ()
Original file line number Diff line number Diff line change 77import pathlib
88
99from frequenz .channels .util import FileWatcher , Select , Timer
10- from frequenz .channels .util ._file_watcher import EventType
1110
1211
1312async def test_file_watcher (tmp_path : pathlib .Path ) -> None :
@@ -45,7 +44,9 @@ async def test_file_watcher_change_types(tmp_path: pathlib.Path) -> None:
4544 Created by pytest.
4645 """
4746 filename = tmp_path / "test-file"
48- file_watcher = FileWatcher (paths = [str (tmp_path )], event_types = {EventType .DELETE })
47+ file_watcher = FileWatcher (
48+ paths = [str (tmp_path )], event_types = {FileWatcher .EventType .DELETE }
49+ )
4950
5051 select = Select (
5152 write_timer = Timer (0.1 ), deletion_timer = Timer (0.5 ), watcher = file_watcher
You can’t perform that action at this time.
0 commit comments