diff --git a/features/steps/core.py b/features/steps/core.py index 7262ac74..73ed75a3 100644 --- a/features/steps/core.py +++ b/features/steps/core.py @@ -61,11 +61,12 @@ def open_journal(journal_name="default"): config = util.load_config(install.CONFIG_FILE_PATH) journal_conf = config["journals"][journal_name] - # We can override the default config on a by-journal basis + if type(journal_conf) is dict: + # We can override the default config on a by-journal basis config.update(journal_conf) - # But also just give them a string to point to the journal file else: + # But also just give them a string to point to the journal file config["journal"] = journal_conf return Journal.open_journal(journal_name, config) @@ -129,25 +130,27 @@ def run_with_input(context, command, inputs=""): text = iter([inputs]) args = ushlex(command)[1:] - # fmt: off - # black needs the 'on' and 'off' to be at the same indentation level - with patch("builtins.input", side_effect=_mock_input(text)) as mock_input,\ - patch("getpass.getpass", side_effect=_mock_getpass(text)) as mock_getpass,\ - patch("sys.stdin.read", side_effect=text) as mock_read: - try: - cli.run(args or []) - context.exit_status = 0 - except SystemExit as e: - context.exit_status = e.code - # at least one of the mocked input methods got called - assert mock_input.called or mock_getpass.called or mock_read.called - # all inputs were used - try: - next(text) - assert False, "Not all inputs were consumed" - except StopIteration: - pass + # fmt: off + # see: https://github.com/psf/black/issues/557 + with patch("builtins.input", side_effect=_mock_input(text)) as mock_input, \ + patch("getpass.getpass", side_effect=_mock_getpass(text)) as mock_getpass, \ + patch("sys.stdin.read", side_effect=text) as mock_read: + + try: + cli.run(args or []) + context.exit_status = 0 + except SystemExit as e: + context.exit_status = e.code + + # at least one of the mocked input methods got called + assert mock_input.called or mock_getpass.called or mock_read.called + # all inputs were used + try: + next(text) + assert False, "Not all inputs were consumed" + except StopIteration: + pass # fmt: on diff --git a/jrnl/Journal.py b/jrnl/Journal.py index bd23ba9f..e5bf4ecc 100644 --- a/jrnl/Journal.py +++ b/jrnl/Journal.py @@ -231,18 +231,16 @@ class Journal: result = [ entry for entry in self.entries - if ( - (not tags or tagged(entry.tags)) - and (not starred or entry.starred) - and (not start_date or entry.date >= start_date) - and (not end_date or entry.date <= end_date) - and (not exclude or not excluded(entry.tags)) - and ( - not contains - or ( - contains_lower in entry.title.casefold() - or contains_lower in entry.body.casefold() - ) + if (not tags or tagged(entry.tags)) + and (not starred or entry.starred) + and (not start_date or entry.date >= start_date) + and (not end_date or entry.date <= end_date) + and (not exclude or not excluded(entry.tags)) + and ( + not contains + or ( + contains_lower in entry.title.casefold() + or contains_lower in entry.body.casefold() ) ) ]