Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add search #287

Draft
wants to merge 6 commits into
base: features
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Parameter renamings, default start date to today
  • Loading branch information
nicfb committed Nov 18, 2022
commit 16cbbb6db632537f9c810b3d2bf633a9c5a440ea
16 changes: 8 additions & 8 deletions kosmorro/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def run():
output = get_search_information(
args.search,
args.from_,
args.to,
args.until,
timezone,
output_format,
use_colors,
Expand Down Expand Up @@ -245,20 +245,20 @@ def get_information(
def get_search_information(
requested_events: [EventType],
search_from: date,
search_to: date,
search_until: date,
timezone: int,
output_format: str,
colors: bool,
show_graph: bool,
) -> dumper.Dumper:
try:
if search_from is None or search_to is None:
if search_until is None:
raise SearchDatesNotGivenError

event_types = [EventType[event.upper()] for event in requested_events]
from_ = parse_date(search_from)
to = parse_date(search_to)
events_list = search_events(event_types, to, from_, timezone)
until = parse_date(search_until)
events_list = search_events(event_types, until, from_, timezone)

return get_dumpers()[output_format](
ephemerides=[],
Expand Down Expand Up @@ -398,11 +398,11 @@ def get_args(output_formats: [str]):
"--from",
dest="from_",
type=str,
default=None,
help=_("The date to begin searching for events."),
default=today.strftime("%Y-%m-%d"),
help=_("The date to begin searching for events. Default is today."),
)
parser.add_argument(
"--to", type=str, default=None, help=_("The date to end searching for events.")
"--until", type=str, default=None, help=_("The date to end searching for events.")
)
parser.add_argument(
"--no-colors",
Expand Down
2 changes: 1 addition & 1 deletion kosmorro/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class SearchDatesNotGivenError(RuntimeError):
def __init__(self):
super().__init__()
self.msg = _(
"Both 'from' and 'to' dates are required when searching for events."
"Search end date (--until) is required when searching events.'"
)


Expand Down