22pycaching - Geocaching for Python
33=================================
44
5- A Python 3 interface for working with Geocaching.com website.
6-
75--------
86Features
97--------
108
119- **login ** to Geocaching.com
1210- **search ** caches
13-
11+
1412 - normal search (unlimited number of caches from any point)
1513 - quick search (all caches inside some area)
16-
17- - **load cache ** and its details by WP or URL
14+
15+ - **load cache ** and its details
1816
1917 - normal loading (loads all details)
2018 - quick loading (loads just basic info very quickly)
2119 - lazy loading (create cache object and load info on demand)
2220 - load logbook for given cache
2321
2422- **post log ** to cache logbook
25-
2623- **load trackable ** details by tracking code
2724- **geocode ** given location
2825
@@ -42,13 +39,15 @@ Dev version - manually from GIT:
4239.. code :: bash
4340
4441 git clone https://github.com/tomasbedrich/pycaching.git
42+ pip install ./pycaching
4543
46- Requirements
47- ~~~~~~~~~~~~
44+ Pycaching has following requirements:
45+
46+ .. code ::
4847
49- - Python >= 3.4
50- - MechanicalSoup >= 0.3.0
51- - geopy >= 1.0.0
48+ Python>= 3.4
49+ MechanicalSoup>= 0.3.0
50+ geopy>= 1.0.0
5251
5352
5453-------------
@@ -63,143 +62,100 @@ Login
6362 import pycaching
6463 geocaching = pycaching.login(" user" , " pass" )
6564
66- The above is just shortcut for:
67-
68- .. code :: python
69-
70- from pycaching import Geocaching
71- geocaching = Geocaching()
72- geocaching.login(" user" , " pass" )
73-
7465 Load a cache details
7566~~~~~~~~~~~~~~~~~~~~
7667
7768.. code :: python
7869
79- import pycaching
70+ cache = geocaching.get_cache(" GC1PAR2" )
71+ print (cache.name) # cache.load() is automatically called
72+ print (cache.location) # stored in cache, printed immediately
8073
81- geocaching = pycaching.login(" user" , " pass" )
82- cache = geocaching.load_cache(" GC1PAR2" )
83- print (cache.name)
74+ This uses lazy loading, so the ``Cache `` object is created immediately and the
75+ page is loaded when needed (accessing the name).
8476
85- Using lazy loading:
77+ You can use different method of loading cache details. It will be much faster,
78+ but it will load less details:
8679
8780.. code :: python
8881
89- from pycaching import Geocaching, Cache
82+ cache = geocaching.get_cache(" GC1PAR2" )
83+ cache.load_quick() # takes a small while
84+ print (cache.name) # stored in cache, printed immediately
85+ print (cache.location) # NOT stored in cache, will trigger full loading
9086
91- geocaching = Geocaching()
92- geocaching.login(" user" , " pass" )
93- cache = Cache(" GC1PAR2" , geocaching)
94- print (cache.name)
87+ You can also load a logbook for cache:
9588
96- The difference is, that ``Cache `` object is created immediately and the
97- page is loaded when needed (accessing the name).
89+ .. code :: python
9890
99- Post a new log to a cache
100- ~~~~~~~~~~~~~~~~~~~~~~~~~
91+ for log in cache.load_logbook( limit = 200 ):
92+ print (log.visited, log.type, log.author, log.text)
10193
102- :: code:: python
94+ Or its trackables:
10395
104- from pycaching import Geocaching, Cache, Log, enums
105- from datetime import date
96+ .. code :: python
10697
107- geocaching = Geocaching()
108- geocaching.login("user", "pass")
109- cache = Cache("GC1PAR2", geocaching)
98+ for trackable in cache.load_trackables(limit = 5 ):
99+ print (trackable.name)
110100
111- log = Log()
112- log.text = "Found cache in the rain. Nice Place, TFTC!"
113- log.type = enums.LogType.found_it
114- log.visited = date.today
101+ Post a log to cache
102+ ~~~~~~~~~~~~~~~~~~~
115103
116- cache.post_log(log)
104+ .. code :: python
117105
118- Find all traditional caches around
119- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
106+ geocaching.post_log(" GC1PAR2" , " Found cache in the rain. Nice Place, TFTC!" )
120107
121- Notice the ``limit `` in search function. It is because ``search() ``
122- returns a generator object, which would fetch the caches forever in case
123- of simple loop.
108+ It is also possible to call post_log on ``Cache `` object, but you would have
109+ to create ``Log `` object manually and pass it to this method.
110+
111+ Search for all traditional caches around
112+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
124113
125114.. code :: python
126115
127- from pycaching import Geocaching, Point, Type
116+ from pycaching import Point
117+ from pycaching.cache import Type
128118
129119 point = Point(56.25263 , 15.26738 )
130- geocaching = Geocaching()
131- geocaching.login(" user" , " pass" )
132120
133121 for cache in geocaching.search(point, limit = 50 ):
134122 if cache.type == Type.traditional:
135123 print (cache.name)
136124
137- Find all caches on some adress
138- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
125+ Notice the ``limit `` in search function. It is because ``search() ``
126+ returns a generator object, which would fetch the caches forever in case
127+ of simple loop.
139128
140- .. code :: python
129+ Geocode adress and search around
130+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
141131
142- import pycaching
132+ .. code :: python
143133
144- geocaching = pycaching.login(" user" , " pass" )
145- point = geocaching.geocode(" 10900 Euclid Ave in Cleveland" )
134+ point = geocaching.geocode(" Prague" )
146135
147136 for cache in geocaching.search(point, limit = 10 ):
148137 print (cache.name)
149138
150- Find approximate location of caches in area
151- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
139+ Find caches with their approximate locations in some area
140+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
152141
153142.. code :: python
154143
155- from pycaching import Geocaching, Point, Rectangle
144+ from pycaching import Point, Rectangle
156145
157- geocaching = pycaching.Geocaching()
158- geocaching.login(" user" , " pass" )
159146 rect = Rectangle(Point(60.15 , 24.95 ), Point(60.17 , 25.00 ))
160147
161148 for cache in geocaching.search_quick(rect, strict = True ):
162149 print (cache.name, cache.location.precision)
163150
164151
165- Load trackable details
166- ~~~~~~~~~~~~~~~~~~~~~~
167-
168- .. code :: python
169-
170- import pycaching
171- geocaching = pycaching.login(" user" , " pass" )
172- trackable = geocaching.load_trackable(" TB3ZGT2" )
173- print (trackable.name, trackable.goal, trackable.description, trackable.location)
174-
175-
176- Find all nearby caches with trackables in them
177- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
178-
179- .. code :: python
180-
181- from pycaching import Geocaching, Point
182-
183- point = Point(56.25263 , 15.26738 )
184- geocaching = Geocaching()
185- geocaching.login(" user" , " pass" )
186-
187- for cache in geocaching.search(point, limit = 50 ):
188- if len (cache.trackables) > 0 :
189- print (cache.name)
190-
191-
192- Load logbook for a cache
152+ Load a trackable details
193153~~~~~~~~~~~~~~~~~~~~~~~~
194154
195155.. code :: python
196156
197- import pycaching
198-
199- geocaching = pycaching.login(" user" , " pass" )
200- cache = geocaching.load_cache(" GC1PAR2" )
201- for log in cache.load_logbook(limit = 200 ):
202- print (log.visited, log.type, log.author, log.text)
157+ trackable = geocaching.get_trackable(" TB3ZGT2" )
158+ print (trackable.name, trackable.goal, trackable.description, trackable.location)
203159
204160
205161--------
@@ -229,10 +185,12 @@ Although the new version was massively rewritten, I'd like to thank to their aut
229185Author
230186~~~~~~
231187
232- | Tomas Bedrich
188+ | Tomáš Bedřich
233189| `tbedrich.cz <http://tbedrich.cz>`__
234190235191
192+ Thanks to `all contributors <https://github.com/tomasbedrich/pycaching/graphs/contributors >`__!
193+
236194------------------------------------------------------------------------------------
237195
238196|Build Status | |Coverage Status | |PyPI monthly downloads |
0 commit comments