mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-07-07 08:46:13 +02:00
Drop use of codecs package
Use builtins.open() instead
This commit is contained in:
parent
65adb92ed4
commit
827a598dd8
6 changed files with 12 additions and 18 deletions
|
@ -1,7 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
import codecs
|
||||
import sys
|
||||
from .. import util
|
||||
|
||||
|
@ -16,7 +15,7 @@ class JRNLImporter:
|
|||
old_cnt = len(journal.entries)
|
||||
old_entries = journal.entries
|
||||
if input:
|
||||
with codecs.open(input, "r", "utf-8") as f:
|
||||
with open(input, "r", encoding="utf-8") as f:
|
||||
other_journal_txt = f.read()
|
||||
else:
|
||||
try:
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
import codecs
|
||||
from ..util import slugify
|
||||
import os
|
||||
from ..util import ERROR_COLOR, RESET_COLOR
|
||||
|
@ -26,7 +25,7 @@ class TextExporter:
|
|||
def write_file(cls, journal, path):
|
||||
"""Exports a journal into a single file."""
|
||||
try:
|
||||
with codecs.open(path, "w", "utf-8") as f:
|
||||
with open(path, "w", encoding="utf-8") as f:
|
||||
f.write(cls.export_journal(journal))
|
||||
return f"[Journal exported to {path}]"
|
||||
except IOError as e:
|
||||
|
@ -42,7 +41,7 @@ class TextExporter:
|
|||
for entry in journal.entries:
|
||||
try:
|
||||
full_path = os.path.join(path, cls.make_filename(entry))
|
||||
with codecs.open(full_path, "w", "utf-8") as f:
|
||||
with open(full_path, "w", encoding="utf-8") as f:
|
||||
f.write(cls.export_entry(entry))
|
||||
except IOError as e:
|
||||
return "[{2}ERROR{3}: {0} {1}]".format(e.filename, e.strerror, ERROR_COLOR, RESET_COLOR)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue