Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
83 changes: 42 additions & 41 deletions pycaching/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,74 +29,75 @@ class Cache(object):
on geocaching.com.
"""

# generated by Util.get_possible_attributes()
# generated by util.get_possible_attributes()
# TODO: smarter way of keeping attributes up to date
_possible_attributes = {
"abandonedbuilding": "Abandoned Structure",
"available": "Available at All Times",
"AbandonedBuilding": "Abandoned Structure",
"UV": "UV Light Required",
"available": "Available at all times",
"bicycles": "Bicycles",
"boat": "Boat",
"campfires": "Campfires",
"camping": "Camping Available",
"cliff": "Cliff / Falling Rocks",
"climbing": "Difficult Climbing",
"cow": "Watch for Livestock",
"danger": "Dangerous Area",
"dangerousanimals": "Dangerous Animals",
"camping": "Camping available",
"cliff": "Cliff / falling rocks",
"climbing": "Difficult climbing",
"cow": "Watch for livestock",
"danger": "Dangerous area",
"dangerousanimals": "Dangerous animals",
"dogs": "Dogs",
"fee": "Access or Parking Fee",
"fee": "Access or parking fee",
"field_puzzle": "Field Puzzle",
"firstaid": "Needs Maintenance",
"flashlight": "Flashlight Required",
"firstaid": "Needs maintenance",
"flashlight": "Flashlight required",
"food": "Food Nearby",
"frontyard": "Front Yard(Private Residence)",
"frontyard": "Front Yard (Private Residence)",
"fuel": "Fuel Nearby",
"geotour": "GeoTour Cache",
"geotour": "Geotour",
"hike_long": "Long Hike (+10km)",
"hike_med": "Medium Hike (1km-10km)",
"hike_short": "Short Hike (Less than 1km)",
"hiking": "Significant Hike",
"hike_med": "Medium hike (1km-10km)",
"hike_short": "Short hike (less than 1km)",
"hiking": "Significant hike",
"horses": "Horses",
"hunting": "Hunting",
"jeeps": "Off-Road Vehicles",
"kids": "Recommended for Kids",
"jeeps": "Off-road vehicles",
"kids": "Recommended for kids",
"landf": "Lost And Found Tour",
"mine": "Abandoned Mines",
"motorcycles": "Motortcycles",
"night": "Recommended at Night",
"mine": "Abandoned mines",
"motorcycles": "Motorcycles",
"night": "Recommended at night",
"nightcache": "Night Cache",
"onehour": "Takes Less Than an Hour",
"parking": "Parking Available",
"onehour": "Takes less than one hour",
"parking": "Parking available",
"parkngrab": "Park and Grab",
"partnership": "Partnership Cache",
"phone": "Telephone Nearby",
"picnic": "Picnic Tables Nearby",
"poisonoak": "Poisonous Plants",
"public": "Public Transportation",
"phone": "Telephone nearby",
"picnic": "Picnic tables nearby",
"poisonoak": "Poison plants",
"public": "Public transportation",
"quads": "Quads",
"rappelling": "Climbing Gear",
"restrooms": "Public Restrooms Nearby",
"rappelling": "Climbing gear",
"restrooms": "Public restrooms nearby",
"rv": "Truck Driver/RV",
"s-tool": "Special Tool Required",
"scenic": "Scenic View",
"scuba": "Scuba Gear",
"scenic": "Scenic view",
"scuba": "Scuba gear",
"seasonal": "Seasonal Access",
"skiis": "Cross Country Skis",
"snowmobiles": "Snowmobiles",
"snowshoes": "Snowshoes",
"stealth": "Stealth Required",
"stroller": "Stroller Accessible",
"swimming": "May Require Swimming",
"stealth": "Stealth required",
"strike": "Not allowed",
"stroller": "Stroller accessible",
"swimming": "May require swimming",
"teamwork": "Teamwork Required",
"thorn": "Thorns",
"ticks": "Ticks",
"touristok": "Tourist Friendly",
"touristOK": "Tourist Friendly",
"treeclimbing": "Tree Climbing",
"uv": "UV Light Required",
"wading": "May Require Wading",
"water": "Drinking Water Nearby",
"wheelchair": "Wheelchair Accessible",
"winter": "Available During Winter",
"wading": "May require wading",
"water": "Drinking water nearby",
"wheelchair": "Wheelchair accessible",
"winter": "Available during winter",
"wirelessbeacon": "Wireless Beacon"
}

Expand Down
12 changes: 4 additions & 8 deletions pycaching/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM"
)

_attributes_url = "http://www.geocaching.com/about/icons.aspx"
_attributes_url = "https://www.geocaching.com/app/src/assets/sprites/attributes.svg"


def lazy_loaded(func):
Expand Down Expand Up @@ -93,7 +93,6 @@ def format_date(date, user_date_format):
def get_possible_attributes(*, session=None):
"""Return a dict of all possible attributes parsed from Groundspeak's website."""
# imports are here not to slow down other parts of program which normally doesn't use this method
from itertools import chain
import requests
from bs4 import BeautifulSoup

Expand All @@ -104,9 +103,6 @@ def get_possible_attributes(*, session=None):
except requests.exceptions.ConnectionError as e:
raise errors.Error("Cannot load attributes page.") from e

# get all <img>s containing attributes from all <dl>s with specific class
images = chain(*map(lambda i: i.find_all("img"), page.find_all("dl", "AttributesList")))
# create dict as {"machine name": "human description"}
attributes = {i.get("src").split("/")[-1].rsplit("-", 1)[0]: i.get("alt") for i in images}

return attributes
symbols = page.select("symbol")
# {"machine name": "human description"}
return {s.get("id"): s.select_one("title").text for s in symbols}
Loading