mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 08:38:32 +02:00
fix various small issues in the codebase
This commit is contained in:
parent
abad3a3a79
commit
e3a46e9846
10 changed files with 6 additions and 25 deletions
|
@ -10,13 +10,10 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import parsedatetime as pdt
|
import parsedatetime as pdt
|
||||||
import time
|
import time
|
||||||
from codecs import encode, decode
|
|
||||||
import os
|
import os
|
||||||
import ast
|
import ast
|
||||||
import json
|
|
||||||
import yaml
|
import yaml
|
||||||
import keyring
|
import keyring
|
||||||
import tzlocal
|
|
||||||
import shlex
|
import shlex
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
@ -203,7 +200,6 @@ def check_output(context, text=None):
|
||||||
@then('the output should contain "{text}" in the local time')
|
@then('the output should contain "{text}" in the local time')
|
||||||
def check_output_time_inline(context, text):
|
def check_output_time_inline(context, text):
|
||||||
out = context.stdout_capture.getvalue()
|
out = context.stdout_capture.getvalue()
|
||||||
local_tz = tzlocal.get_localzone()
|
|
||||||
date, flag = CALENDAR.parse(text)
|
date, flag = CALENDAR.parse(text)
|
||||||
output_date = time.strftime("%Y-%m-%d %H:%M", date)
|
output_date = time.strftime("%Y-%m-%d %H:%M", date)
|
||||||
assert output_date in out, output_date
|
assert output_date in out, output_date
|
||||||
|
@ -230,7 +226,7 @@ def check_output_inline(context, text=None, text2=None):
|
||||||
@then("the error output should contain")
|
@then("the error output should contain")
|
||||||
@then('the error output should contain "{text}"')
|
@then('the error output should contain "{text}"')
|
||||||
@then('the error output should contain "{text}" or "{text2}"')
|
@then('the error output should contain "{text}" or "{text2}"')
|
||||||
def check_output_inline(context, text=None, text2=None):
|
def check_error_output_inline(context, text=None, text2=None):
|
||||||
text = text or context.text
|
text = text or context.text
|
||||||
out = context.stderr_capture.getvalue()
|
out = context.stderr_capture.getvalue()
|
||||||
assert text in out or text2 in out, text or text2
|
assert text in out or text2 in out, text or text2
|
||||||
|
@ -299,7 +295,6 @@ def check_journal_entries(context, number, journal_name="default"):
|
||||||
|
|
||||||
@when("the journal directory is listed")
|
@when("the journal directory is listed")
|
||||||
def list_journal_directory(context, journal="default"):
|
def list_journal_directory(context, journal="default"):
|
||||||
files = []
|
|
||||||
with open(install.CONFIG_FILE_PATH) as config_file:
|
with open(install.CONFIG_FILE_PATH) as config_file:
|
||||||
config = yaml.load(config_file, Loader=yaml.FullLoader)
|
config = yaml.load(config_file, Loader=yaml.FullLoader)
|
||||||
journal_path = config["journals"][journal]
|
journal_path = config["journals"][journal]
|
||||||
|
|
|
@ -10,7 +10,6 @@ import sys
|
||||||
import os
|
import os
|
||||||
import base64
|
import base64
|
||||||
import logging
|
import logging
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger()
|
log = logging.getLogger()
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
|
||||||
from __future__ import absolute_import, unicode_literals
|
from __future__ import absolute_import, unicode_literals
|
||||||
from . import Entry
|
|
||||||
from . import Journal
|
from . import Journal
|
||||||
import codecs
|
import codecs
|
||||||
import os
|
import os
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from .__version__ import __version__
|
from .__version__ import __version__
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
|
@ -365,7 +365,7 @@ def run(manual_args=None):
|
||||||
try:
|
try:
|
||||||
journal = open_journal(journal_name, config)
|
journal = open_journal(journal_name, config)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print(f"[Interrupted while opening journal]", file=sys.stderr)
|
print("[Interrupted while opening journal]", file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# Import mode
|
# Import mode
|
||||||
|
|
|
@ -1,14 +1,11 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import glob
|
import glob
|
||||||
import getpass
|
|
||||||
import os
|
import os
|
||||||
import xdg.BaseDirectory
|
import xdg.BaseDirectory
|
||||||
from . import util
|
from . import util
|
||||||
from . import upgrade
|
from . import upgrade
|
||||||
from . import __version__
|
from . import __version__
|
||||||
from .Journal import PlainJournal
|
|
||||||
from .EncryptedJournal import EncryptedJournal
|
|
||||||
from .util import UserAbort, verify_config
|
from .util import UserAbort, verify_config
|
||||||
import yaml
|
import yaml
|
||||||
import logging
|
import logging
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from .. import util
|
|
||||||
|
|
||||||
|
|
||||||
class JRNLImporter:
|
class JRNLImporter:
|
||||||
|
@ -15,7 +14,6 @@ class JRNLImporter:
|
||||||
"""Imports from an existing file if input is specified, and
|
"""Imports from an existing file if input is specified, and
|
||||||
standard input otherwise."""
|
standard input otherwise."""
|
||||||
old_cnt = len(journal.entries)
|
old_cnt = len(journal.entries)
|
||||||
old_entries = journal.entries
|
|
||||||
if input:
|
if input:
|
||||||
with open(input, "r", encoding="utf-8") as f:
|
with open(input, "r", encoding="utf-8") as f:
|
||||||
other_journal_txt = f.read()
|
other_journal_txt = f.read()
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
|
||||||
from .text_exporter import TextExporter
|
from .text_exporter import TextExporter
|
||||||
import os
|
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
from ..util import WARNING_COLOR, RESET_COLOR
|
from ..util import WARNING_COLOR, RESET_COLOR
|
||||||
|
|
|
@ -6,9 +6,7 @@ EXPRESSION_RE = r"[\[\]():.a-zA-Z0-9_]*"
|
||||||
PRINT_RE = r"{{ *(.+?) *}}"
|
PRINT_RE = r"{{ *(.+?) *}}"
|
||||||
START_BLOCK_RE = r"{% *(if|for) +(.+?) *%}"
|
START_BLOCK_RE = r"{% *(if|for) +(.+?) *%}"
|
||||||
END_BLOCK_RE = r"{% *end(for|if) *%}"
|
END_BLOCK_RE = r"{% *end(for|if) *%}"
|
||||||
FOR_RE = r"{{% *for +({varname}) +in +([^%]+) *%}}".format(
|
FOR_RE = r"{{% *for +({varname}) +in +([^%]+) *%}}".format(varname=VAR_RE)
|
||||||
varname=VAR_RE, expression=EXPRESSION_RE
|
|
||||||
)
|
|
||||||
IF_RE = r"{% *if +(.+?) *%}"
|
IF_RE = r"{% *if +(.+?) *%}"
|
||||||
BLOCK_RE = r"{% *block +(.+?) *%}((?:.|\n)+?){% *endblock *%}"
|
BLOCK_RE = r"{% *block +(.+?) *%}((?:.|\n)+?){% *endblock *%}"
|
||||||
INCLUDE_RE = r"{% *include +(.+?) *%}"
|
INCLUDE_RE = r"{% *include +(.+?) *%}"
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
|
||||||
from .text_exporter import TextExporter
|
from .text_exporter import TextExporter
|
||||||
import os
|
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
from ..util import WARNING_COLOR, ERROR_COLOR, RESET_COLOR
|
from ..util import WARNING_COLOR, ERROR_COLOR, RESET_COLOR
|
||||||
|
@ -19,10 +18,9 @@ class YAMLExporter(TextExporter):
|
||||||
"""Returns a markdown representation of a single entry, with YAML front matter."""
|
"""Returns a markdown representation of a single entry, with YAML front matter."""
|
||||||
if to_multifile is False:
|
if to_multifile is False:
|
||||||
print(
|
print(
|
||||||
"{}ERROR{}: YAML export must be to individual files. Please \
|
f"{ERROR_COLOR}ERROR{RESET_COLOR}: YAML export must be to individual files. Please \
|
||||||
specify a directory to export to.".format(
|
specify a directory to export to.",
|
||||||
ERROR_COLOR, RESET_COLOR, file=sys.stderr
|
file=sys.stderr,
|
||||||
)
|
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue