Merge lp:~andrewmccarthy/pythondoc-lens/use-local-docs into lp:pythondoc-lens

Proposed by Andrew McCarthy
Status: Merged
Approved by: Pablo Rubianes
Approved revision: 3
Merged at revision: 3
Proposed branch: lp:~andrewmccarthy/pythondoc-lens/use-local-docs
Merge into: lp:pythondoc-lens
Diff against target: 30 lines (+8/-1)
1 file modified
pythondoc_lens/__init__.py (+8/-1)
To merge this branch: bzr merge lp:~andrewmccarthy/pythondoc-lens/use-local-docs
Reviewer Review Type Date Requested Status
Pablo Rubianes Approve
Review via email: mp+132765@code.launchpad.net

Description of the change

A simple change that checks for already-installed local python docs by looking at /usr/share/doc/python*-doc

To post a comment you must log in.
Revision history for this message
Pablo Rubianes (pablorubianes-uy) wrote :

This works great

review: Approve
Revision history for this message
Pablo Rubianes (pablorubianes-uy) wrote :

This works great

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'pythondoc_lens/__init__.py'
2--- pythondoc_lens/__init__.py 2012-07-16 01:28:19 +0000
3+++ pythondoc_lens/__init__.py 2012-11-03 07:29:20 +0000
4@@ -1,5 +1,7 @@
5 import logging
6 import optparse
7+import glob
8+import os.path
9
10 import urllib2
11 from BeautifulSoup import BeautifulSoup
12@@ -47,6 +49,11 @@
13 return results
14 print 'Searching for:', search
15 if not self.shows:
16+ # Look for a local python-doc package
17+ localdoc = glob.glob('/usr/share/doc/python*-doc/html/genindex-all.html')
18+ if len(localdoc) > 0:
19+ localdoc.sort()
20+ self.doc = 'file://' + os.path.dirname(localdoc[-1]) + os.sep
21 url = self.doc + 'genindex-all.html'
22 page = urllib2.urlopen(url).read()
23 soup = BeautifulSoup(page)
24@@ -66,4 +73,4 @@
25 for name in selected:
26 results.append((name, self.shows[name]))
27
28- return results
29\ No newline at end of file
30+ return results

Subscribers

People subscribed via source and target branches