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
3ba34834
Commit
3ba34834
authored
Nov 17, 2016
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only emit a file update event when todo.txt was changed externally
parent
e0a54122
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
1 deletion
+8
-1
topydo/lib/TodoFile.py
topydo/lib/TodoFile.py
+8
-1
No files found.
topydo/lib/TodoFile.py
View file @
3ba34834
...
...
@@ -30,6 +30,7 @@ class TodoFile(object):
def
__init__
(
self
,
p_path
,
p_on_update
=
None
):
self
.
path
=
os
.
path
.
abspath
(
p_path
)
self
.
write_lock
=
False
if
p_on_update
:
from
watchdog.observers
import
Observer
...
...
@@ -39,7 +40,7 @@ class TodoFile(object):
def
_handle
(
_
,
p_event
):
right_type
=
isinstance
(
p_event
,
FileCreatedEvent
)
or
isinstance
(
p_event
,
FileModifiedEvent
)
if
right_type
and
p_event
.
src_path
==
self
.
path
:
if
not
self
.
write_lock
and
right_type
and
p_event
.
src_path
==
self
.
path
:
p_on_update
()
def
on_created
(
self
,
p_event
):
...
...
@@ -75,6 +76,11 @@ class TodoFile(object):
p_todos can be a list of todo items, or a string that is just written
to the file.
"""
# make sure not to reread the todo file because this instance is
# actually writing it
self
.
write_lock
=
True
todofile
=
codecs
.
open
(
self
.
path
,
'w'
,
encoding
=
"utf-8"
)
if
p_todos
is
list
:
...
...
@@ -86,3 +92,4 @@ class TodoFile(object):
todofile
.
write
(
"
\
n
"
)
todofile
.
close
()
self
.
write_lock
=
False
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