juftin / camply

camply, the campsite finder ⛺️ - a tool to find campsites at sold out campgrounds through sites like recreation.gov
https://juftin.com/camply/
MIT License
476 stars 93 forks source link

Trouble using search yaml file with equipment option #283

Closed biojerm closed 1 year ago

biojerm commented 1 year ago

Describe the bug

Searching for campsites using a yaml file config is not working as I would expected. The equipment type does not seem to be recognized. I am seeing these warnings in the log. This could be user error, but I put as much detail as I could figure out.

[2023-07-20 22:41:06] WARNING  Equipment name not recognized: R. This won't be used for filtering. Acceptable options
                               are: tent, rv, trailer, vehicle
[2023-07-20 22:41:06] WARNING  Equipment name not recognized: 2. This won't be used for filtering. Acceptable options
                               are: tent, rv, trailer, vehicle

I put a breakpoint at line 158 in search_recreationdotgov.py and saw that the equipment tuple was over expanded

 if isinstance(equipment, (list, tuple)):
157                 final_equipment = []
158                 breakpoint()
159  ->             for equipment_name, equipment_length in equipment:
160                     if (
(Pdb) equipment
[('R', 'V'), ('2', '5')]

Also the length of 25 is being treated as a string (and split).

Original Camply Command (with --debug)

pipenv run camply campsites --yaml-config proof.yaml --debug > debug.txt

Expected behavior I expected the equipment type to be parsed into an equipment type string and length integer.

Console Output (with --debug)

debug.txt

Additional context

< Add any other context about the problem here. >

This is my yaml file, it is similar to the sample from the docs.

    - 2991
start_date: 2023-07-29
end_date: 2023-08-02
nights: 1
equipment: [RV, 25]

I tired to do as suggested in the docs of

...
equipment: 
  - [RV, 25]. # Make this an array.

But i get this error

ValidationError: 4 validation errors for YamlSearchFile
equipment
  value is not a valid integer (type=type_error.integer)
equipment -> 0
  value is not a valid integer (type=type_error.integer)
equipment
  str type expected (type=type_error.str)
equipment -> 0
  str type expected (type=type_error.str)

I am not sure if this is 1 or 2 issues.

Thanks in advance!