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

Error while listing for found caches "AttributeError: 'NoneType' object has no attribute 'find_next'" #188

Closed
MZCacheHunter opened this issue Aug 21, 2022 · 5 comments

Comments

@MZCacheHunter
Copy link

MZCacheHunter commented Aug 21, 2022

Hi there,

I just tried to use the example code for listing my own found caches:

import pycaching
from pycaching.log import Type as log_type

geocaching = pycaching.login()
for find in geocaching.my_finds(limit=5):
    print(find.name)
geocaching.logout()

Resulting in:

Traceback (most recent call last):
  File "./pycache-found-logs.py", line 8, in <module>
    for find in geocaching.my_finds(limit=5):
  File "/Users/michael/Library/Python/3.7/lib/python/site-packages/pycaching/geocaching.py", line 530, in my_logs
    current_cache = self._try_getting_cache_from_guid(guid)
  File "/Users/michael/Library/Python/3.7/lib/python/site-packages/pycaching/geocaching.py", line 499, in _try_getting_cache_from_guid
    return self.get_cache(guid=guid)
  File "/Users/michael/Library/Python/3.7/lib/python/site-packages/pycaching/geocaching.py", line 465, in get_cache
    return self._cache_from_guid(guid)
  File "/Users/michael/Library/Python/3.7/lib/python/site-packages/pycaching/geocaching.py", line 491, in _cache_from_guid
    return Cache._from_print_page(self, guid, print_page)
  File "/Users/michael/Library/Python/3.7/lib/python/site-packages/pycaching/cache.py", line 157, in _from_print_page
    **cache_info["summary"] = content.find("h2", text="Short Description").find_next("div").text
AttributeError: 'NoneType' object has no attribute 'find_next'**

Any help appreciated. Thanks!

@FriedrichFroebel
Copy link
Collaborator

FriedrichFroebel commented Aug 21, 2022

Thanks for your report.

The parser usually expects the language to be set to English. Is this set correctly in your case? Otherwise, please try to check/debug which GC code/GUID actually causes this issue (this might be another edge case as well).

@MZCacheHunter
Copy link
Author

MZCacheHunter commented Aug 25, 2022

Sorry for the confusion caused. There was another userID in the first line of my .gc_credentials file. That user's language settings weren't set to English.
Embarrassed, I feel ashamed of myself. Sorry.

@FriedrichFroebel
Copy link
Collaborator

No problem, glad that this turned out to be a usage error instead of one with the library.

@tomasbedrich
Copy link
Owner

Still, the learning for us may be to add something like:

assert page.find_by_id("some-pre-known-element").get_text() == "Expected English label", "Pycaching expects English ...."

What do you think, @FriedrichFroebel ?

@FriedrichFroebel
Copy link
Collaborator

@tomasbedrich As we are currently doing some more changes to the code anyway, we might want to tackle #136 as well. If we keep the language-independent code from _from_print_page and use this inside the load_by_guid method, this should be fixed for the cache parsing at least (I am not sure if this is an issue for the other parsers as well at the moment). See my comment there as well which includes a proposal for fixing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants