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
515cfe23
Commit
515cfe23
authored
Oct 10, 2016
by
Bram Schoenmakers
Committed by
GitHub
Oct 10, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #143 from mruwek/properly-close-and-save-tempfile
Close temporary file after saving to it
parents
a7c495bf
fc265004
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
topydo/commands/EditCommand.py
topydo/commands/EditCommand.py
+7
-4
No files found.
topydo/commands/EditCommand.py
View file @
515cfe23
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
os
import
os
import
codecs
import
tempfile
import
tempfile
from
subprocess
import
CalledProcessError
,
check_call
from
subprocess
import
CalledProcessError
,
check_call
...
@@ -54,16 +55,16 @@ class EditCommand(MultiCommand):
...
@@ -54,16 +55,16 @@ class EditCommand(MultiCommand):
self
.
multi_mode
=
False
self
.
multi_mode
=
False
def
_todos_to_temp
(
self
):
def
_todos_to_temp
(
self
):
f
=
tempfile
.
NamedTemporaryFile
()
f
=
tempfile
.
NamedTemporaryFile
(
delete
=
False
)
for
todo
in
self
.
todos
:
for
todo
in
self
.
todos
:
f
.
write
((
todo
.
source
()
+
"
\
n
"
).
encode
(
'utf-8'
))
f
.
write
((
todo
.
source
()
+
"
\
n
"
).
encode
(
'utf-8'
))
f
.
seek
(
0
)
f
.
close
(
)
return
f
return
f
def
_todos_from_temp
(
self
,
p_temp_file
):
def
_todos_from_temp
(
self
,
p_temp_file
):
p_temp_file
.
seek
(
0
)
f
=
codecs
.
open
(
p_temp_file
.
name
,
encoding
=
'utf-8'
)
todos
=
p_temp_file
.
read
().
decode
(
'utf-8'
).
splitlines
()
todos
=
f
.
read
(
).
splitlines
()
todo_objs
=
[]
todo_objs
=
[]
for
todo
in
todos
:
for
todo
in
todos
:
...
@@ -121,6 +122,8 @@ class EditCommand(MultiCommand):
...
@@ -121,6 +122,8 @@ class EditCommand(MultiCommand):
else
:
else
:
self
.
error
(
self
.
usage
())
self
.
error
(
self
.
usage
())
os
.
unlink
(
temp_todos
.
name
)
def
_execute_not_multi
(
self
):
def
_execute_not_multi
(
self
):
if
self
.
edit_archive
:
if
self
.
edit_archive
:
archive
=
config
().
archive
()
archive
=
config
().
archive
()
...
...
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