~submarine/ubuntu-scopes/devhelp

« back to all changes in this revision

Viewing changes to src/unity_devhelp_daemon.py

  • Committer: Tarmac
  • Author(s): David Callé
  • Date: 2013-03-21 10:41:53 UTC
  • mfrom: (17.1.2 devhelp)
  • Revision ID: tarmac-20130321104153-0tuw77ksrs5fopxn
Limit the number of results to 50.

Approved by PS Jenkins bot, James Henstridge.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
 
52
52
EXTRA_METADATA = []
53
53
 
 
54
CACHE_DEVHELP = None
54
55
 
55
56
def setup_devhelp():
56
57
    '''
101
102
    Search for help documents matching the search string
102
103
    '''
103
104
    results = []
104
 
    devhelp = setup_devhelp()
 
105
    if len(search) < 2:
 
106
        return results
 
107
    global CACHE_DEVHELP
 
108
    if not CACHE_DEVHELP:
 
109
        print("Loading results...")
 
110
        devhelp = setup_devhelp()
 
111
        CACHE_DEVHELP = devhelp
 
112
    else:
 
113
        devhelp = CACHE_DEVHELP
105
114
    icon_hint = Gio.ThemedIcon.new("text-x-generic").to_string()
106
115
    for data in devhelp:
107
116
        if os.path.exists("/usr/lib/unity-lens-help/icons/%s.svg" % data[2]):
108
117
            icon_hint = "/usr/lib/unity-lens-help/icons/%s.svg" % data[2]
109
118
        if search.lower() in data[0].lower():
 
119
            if len(results) >= 50:
 
120
                break
110
121
            results.append({'uri': data[0],
111
122
                            'icon': icon_hint,
112
123
                            'category': 0,