Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
topydo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
topydo
Commits
a217dab9
Commit
a217dab9
authored
Nov 18, 2016
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass the outer file class to the inner event class
parent
3ba34834
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
+13
-5
topydo/lib/TodoFile.py
topydo/lib/TodoFile.py
+13
-5
No files found.
topydo/lib/TodoFile.py
View file @
a217dab9
...
@@ -37,10 +37,18 @@ class TodoFile(object):
...
@@ -37,10 +37,18 @@ class TodoFile(object):
from
watchdog.events
import
FileSystemEventHandler
,
FileModifiedEvent
,
FileCreatedEvent
from
watchdog.events
import
FileSystemEventHandler
,
FileModifiedEvent
,
FileCreatedEvent
class
EventHandler
(
FileSystemEventHandler
):
class
EventHandler
(
FileSystemEventHandler
):
def
_handle
(
_
,
p_event
):
"""
right_type
=
isinstance
(
p_event
,
FileCreatedEvent
)
or
isinstance
(
p_event
,
FileModifiedEvent
)
Event handler to catch modifications (or creations) of the
current todo.txt file.
"""
def
__init__
(
self
,
p_file
):
super
().
__init__
()
self
.
file
=
p_file
def
_handle
(
self
,
p_event
):
right_type
=
isinstance
(
p_event
,
FileModifiedEvent
)
or
isinstance
(
p_event
,
FileCreatedEvent
)
if
not
self
.
write_lock
and
right_type
and
p_event
.
src_path
==
self
.
path
:
if
not
self
.
file
.
write_lock
and
right_type
and
p_event
.
src_path
==
self
.
file
.
path
:
p_on_update
()
p_on_update
()
def
on_created
(
self
,
p_event
):
def
on_created
(
self
,
p_event
):
...
@@ -54,7 +62,7 @@ class TodoFile(object):
...
@@ -54,7 +62,7 @@ class TodoFile(object):
self
.
_handle
(
p_event
)
self
.
_handle
(
p_event
)
observer
=
Observer
()
observer
=
Observer
()
observer
.
schedule
(
EventHandler
(),
os
.
path
.
dirname
(
self
.
path
))
observer
.
schedule
(
EventHandler
(
self
),
os
.
path
.
dirname
(
self
.
path
))
observer
.
start
()
observer
.
start
()
def
read
(
self
):
def
read
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment