Merge branch 'develop' into black

This commit is contained in:
Jonathan Wren 2019-12-21 12:11:05 -08:00 committed by GitHub
commit e984a9a015
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 32 deletions

View file

@ -61,11 +61,12 @@ def open_journal(journal_name="default"):
config = util.load_config(install.CONFIG_FILE_PATH) config = util.load_config(install.CONFIG_FILE_PATH)
journal_conf = config["journals"][journal_name] journal_conf = config["journals"][journal_name]
# We can override the default config on a by-journal basis
if type(journal_conf) is dict: if type(journal_conf) is dict:
# We can override the default config on a by-journal basis
config.update(journal_conf) config.update(journal_conf)
# But also just give them a string to point to the journal file
else: else:
# But also just give them a string to point to the journal file
config["journal"] = journal_conf config["journal"] = journal_conf
return Journal.open_journal(journal_name, config) return Journal.open_journal(journal_name, config)
@ -129,11 +130,13 @@ def run_with_input(context, command, inputs=""):
text = iter([inputs]) text = iter([inputs])
args = ushlex(command)[1:] args = ushlex(command)[1:]
# fmt: off # fmt: off
# black needs the 'on' and 'off' to be at the same indentation level # see: https://github.com/psf/black/issues/557
with patch("builtins.input", side_effect=_mock_input(text)) as mock_input, \ with patch("builtins.input", side_effect=_mock_input(text)) as mock_input, \
patch("getpass.getpass", side_effect=_mock_getpass(text)) as mock_getpass, \ patch("getpass.getpass", side_effect=_mock_getpass(text)) as mock_getpass, \
patch("sys.stdin.read", side_effect=text) as mock_read: patch("sys.stdin.read", side_effect=text) as mock_read:
try: try:
cli.run(args or []) cli.run(args or [])
context.exit_status = 0 context.exit_status = 0

View file

@ -231,8 +231,7 @@ class Journal:
result = [ result = [
entry entry
for entry in self.entries for entry in self.entries
if ( if (not tags or tagged(entry.tags))
(not tags or tagged(entry.tags))
and (not starred or entry.starred) and (not starred or entry.starred)
and (not start_date or entry.date >= start_date) and (not start_date or entry.date >= start_date)
and (not end_date or entry.date <= end_date) and (not end_date or entry.date <= end_date)
@ -244,7 +243,6 @@ class Journal:
or contains_lower in entry.body.casefold() or contains_lower in entry.body.casefold()
) )
) )
)
] ]
self.entries = result self.entries = result