From defb4b76e089981b7abfa43722e1429ce4220fc7 Mon Sep 17 00:00:00 2001 From: Justin Flannery Date: Fri, 28 Jan 2022 16:53:03 -0700 Subject: [PATCH] BugFix: Campsite Searching in YAML (#59) * --campsites -> YAML * Sphinx Documentation Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- README.md | 29 ++++++++++++++------------- camply/_version.py | 2 +- camply/utils/yaml_utils.py | 2 ++ docs/examples/example_search.yml | 11 +++++----- docs/source/usage.md | 29 ++++++++++++++------------- tests/command_line_test.sh | 1 + tests/yml/example_campsite_search.yml | 10 +++++++++ 7 files changed, 50 insertions(+), 34 deletions(-) create mode 100644 tests/yml/example_campsite_search.yml diff --git a/README.md b/README.md index 34ae07e3..f409dee3 100644 --- a/README.md +++ b/README.md @@ -460,20 +460,21 @@ Sometimes, using a YAML configuration file is easier to manage all of your searc below [YML example file](docs/examples/example_search.yml) and corresponding camply command: ```yaml -provider: RecreationDotGov # RecreationDotGov IF NOT PROVIDED -recreation_area: # (LIST OR SINGLE ENTRY) - - 2991 # Yosemite National Park, CA (All Campgrounds) - - 1074 # Sierra National Forest, CA (All Campgrounds) -campgrounds: null # ENTIRE FIELD CAN BE OMITTED IF NOT USED. # (LIST OR SINGLE ENTRY) -start_date: 2022-09-12 # YYYY-MM-DD -end_date: 2022-09-13 # YYYY-MM-DD -weekends: False # FALSE BY DEFAULT -nights: 1 # 1 BY DEFAULT -continuous: True # DEFAULTS TO TRUE -polling_interval: 5 # DEFAULTS TO 10 , CAN'T BE LESS THAN 5 -notifications: email # (silent, email, pushover, pushbullet), DEFAULTS TO `silent` -search_forever: True # FALSE BY DEFAULT -notify_first_try: False # FALSE BY DEFAULT +provider: RecreationDotGov # RecreationDotGov IF NOT PROVIDED +recreation_area: # (LIST OR SINGLE ENTRY) + - 2991 # Yosemite National Park, CA (All Campgrounds) + - 1074 # Sierra National Forest, CA (All Campgrounds) +campgrounds: null # ENTIRE FIELD CAN BE OMITTED IF NOT USED - (LIST OR SINGLE ENTRY) +campsites: null # OVERRIDES CAMPGROUNDS / RECREATION AREA - (LIST OR SINGLE ENTRY) +start_date: 2022-09-12 # YYYY-MM-DD +end_date: 2022-09-13 # YYYY-MM-DD +weekends: false # FALSE BY DEFAULT +nights: 1 # 1 BY DEFAULT +continuous: true # DEFAULTS TO TRUE +polling_interval: 5 # DEFAULTS TO 10 , CAN'T BE LESS THAN 5 +notifications: email # (silent, email, pushover, pushbullet), DEFAULTS TO `silent` +search_forever: true # FALSE BY DEFAULT +notify_first_try: false # FALSE BY DEFAULT ``` ```shell diff --git a/camply/_version.py b/camply/_version.py index 7c67bbea..c4cd11dd 100644 --- a/camply/_version.py +++ b/camply/_version.py @@ -2,5 +2,5 @@ camply __version__ file """ -__version__ = "0.2.1" +__version__ = "0.2.2" __camply__ = "camply" diff --git a/camply/utils/yaml_utils.py b/camply/utils/yaml_utils.py index ecdf14d5..ebd373db 100644 --- a/camply/utils/yaml_utils.py +++ b/camply/utils/yaml_utils.py @@ -97,6 +97,7 @@ def yaml_file_to_arguments(file_path: str) -> Tuple[str, Dict[str, object], Dict nights = int(yaml_search.get("nights", 1)) recreation_area = yaml_search.get("recreation_area", None) campgrounds = yaml_search.get("campgrounds", None) + campsites = yaml_search.get("campsites", None) weekends_only = yaml_search.get("weekends", False) continuous = yaml_search.get("continuous", True) polling_interval = yaml_search.get("polling_interval", @@ -110,6 +111,7 @@ def yaml_file_to_arguments(file_path: str) -> Tuple[str, Dict[str, object], Dict provider_kwargs = dict(search_window=search_window, recreation_area=recreation_area, campgrounds=campgrounds, + campsites=campsites, weekends_only=weekends_only, nights=nights) search_kwargs = dict( diff --git a/docs/examples/example_search.yml b/docs/examples/example_search.yml index d5c428d7..1b56785e 100644 --- a/docs/examples/example_search.yml +++ b/docs/examples/example_search.yml @@ -1,14 +1,15 @@ provider: RecreationDotGov # RecreationDotGov IF NOT PROVIDED recreation_area: # (LIST OR SINGLE ENTRY) - - 2991 # Yosemite National Park, CA (All Campgrounds) - - 1074 # Sierra National Forest, CA (All Campgrounds) -campgrounds: null # OVERRIDES RECREATION AREA (LIST OR SINGLE ENTRY) + - 2991 # Yosemite National Park, CA (All Campgrounds) + - 1074 # Sierra National Forest, CA (All Campgrounds) +campgrounds: null # ENTIRE FIELD CAN BE OMITTED IF NOT USED - (LIST OR SINGLE ENTRY) +campsites: null # OVERRIDES CAMPGROUNDS / RECREATION AREA - (LIST OR SINGLE ENTRY) start_date: 2022-09-12 # YYYY-MM-DD end_date: 2022-09-13 # YYYY-MM-DD weekends: false # FALSE BY DEFAULT nights: 1 # 1 BY DEFAULT -continuous: false # DEFAULTS TO TRUE +continuous: true # DEFAULTS TO TRUE polling_interval: 5 # DEFAULTS TO 10 , CAN'T BE LESS THAN 5 -notifications: email # (silent, email, pushover, pushbullet), DEFAULTS TO `silent`. LIST OR SINGLE ENTRY +notifications: email # (silent, email, pushover, pushbullet), DEFAULTS TO `silent` search_forever: true # FALSE BY DEFAULT notify_first_try: false # FALSE BY DEFAULT diff --git a/docs/source/usage.md b/docs/source/usage.md index 6480e170..5a715778 100644 --- a/docs/source/usage.md +++ b/docs/source/usage.md @@ -459,20 +459,21 @@ Sometimes, using a YAML configuration file is easier to manage all of your searc below [YML example file](docs/examples/example_search.yml) and corresponding camply command: ```yaml -provider: RecreationDotGov # RecreationDotGov IF NOT PROVIDED -recreation_area: # (LIST OR SINGLE ENTRY) - - 2991 # Yosemite National Park, CA (All Campgrounds) - - 1074 # Sierra National Forest, CA (All Campgrounds) -campgrounds: null # ENTIRE FIELD CAN BE OMITTED IF NOT USED. # (LIST OR SINGLE ENTRY) -start_date: 2022-09-12 # YYYY-MM-DD -end_date: 2022-09-13 # YYYY-MM-DD -weekends: False # FALSE BY DEFAULT -nights: 1 # 1 BY DEFAULT -continuous: True # DEFAULTS TO TRUE -polling_interval: 5 # DEFAULTS TO 10 , CAN'T BE LESS THAN 5 -notifications: email # (silent, email, pushover, pushbullet), DEFAULTS TO `silent` -search_forever: True # FALSE BY DEFAULT -notify_first_try: False # FALSE BY DEFAULT +provider: RecreationDotGov # RecreationDotGov IF NOT PROVIDED +recreation_area: # (LIST OR SINGLE ENTRY) + - 2991 # Yosemite National Park, CA (All Campgrounds) + - 1074 # Sierra National Forest, CA (All Campgrounds) +campgrounds: null # ENTIRE FIELD CAN BE OMITTED IF NOT USED - (LIST OR SINGLE ENTRY) +campsites: null # OVERRIDES CAMPGROUNDS / RECREATION AREA - (LIST OR SINGLE ENTRY) +start_date: 2022-09-12 # YYYY-MM-DD +end_date: 2022-09-13 # YYYY-MM-DD +weekends: false # FALSE BY DEFAULT +nights: 1 # 1 BY DEFAULT +continuous: true # DEFAULTS TO TRUE +polling_interval: 5 # DEFAULTS TO 10 , CAN'T BE LESS THAN 5 +notifications: email # (silent, email, pushover, pushbullet), DEFAULTS TO `silent` +search_forever: true # FALSE BY DEFAULT +notify_first_try: false # FALSE BY DEFAULT ``` ```shell diff --git a/tests/command_line_test.sh b/tests/command_line_test.sh index ac2b2546..365a2690 100755 --- a/tests/command_line_test.sh +++ b/tests/command_line_test.sh @@ -12,3 +12,4 @@ camply campsites --campground 232045 --start-date 2022-07-15 --end-date 2022-10- camply campsites --provider yellowstone --start-date 2022-10-10 --end-date 2022-10-16 camply campsites --campsite 40107 --start-date 2022-09-15 --end-date 2022-09-17 camply campgrounds --campsite 40107 +camply campsites --yml-config tests/yml/example_campsite_search.yml \ No newline at end of file diff --git a/tests/yml/example_campsite_search.yml b/tests/yml/example_campsite_search.yml new file mode 100644 index 00000000..3a08c597 --- /dev/null +++ b/tests/yml/example_campsite_search.yml @@ -0,0 +1,10 @@ +provider: RecreationDotGov # RecreationDotGov IF NOT PROVIDED +recreation_area: # (LIST OR SINGLE ENTRY) + - 2907 # ROCKY MOUNTAIN NATIONAL PARK +campsites: + - 40107 + - 177 +start_date: 2022-09-10 # YYYY-MM-DD +end_date: 2022-09-11 # YYYY-MM-DD +weekends: false # FALSE BY DEFAULT +continuous: false # DEFAULTS TO TRUE