This file is indexed.

/usr/lib/python2.7/dist-packages/unity/emulators/hud.py is in unity-autopilot 7.5.0+18.04.20180413-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
# Copyright 2012 Canonical
# Author: Thomi Richards
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#

from __future__ import absolute_import

from logging import getLogger

from autopilot.input import Keyboard
from autopilot.introspection.dbus import StateNotFoundError
from autopilot.keybindings import KeybindingsHelper
from HTMLParser import HTMLParser
import re

from unity.emulators import UnityIntrospectionObject
from unity.emulators.dash import SearchBar
from unity.emulators.icons import HudEmbeddedIcon, HudLauncherIcon

log = getLogger(__name__)

class HudController(UnityIntrospectionObject, KeybindingsHelper):
    """Proxy object for the Unity Hud Controller."""

    def __init__(self, *args, **kwargs):
        super(HudController, self).__init__(*args, **kwargs)
        self.keyboard = Keyboard.create()

    def get_hud_view(self):
        views = self.get_children_by_type(HudView)
        return views[0] if views else None

    def ensure_hidden(self):
        """Hides the hud if it's not already hidden."""
        if self.visible:
            if self.search_string:
                # need this to clear the search string, and then another to
                # close the hud.
                self.keyboard.press_and_release("Escape")
                self.search_string.wait_for("")
            self.keyboard.press_and_release("Escape")
            self.visible.wait_for(False)

    def ensure_visible(self):
        """Shows the hud if it's not already showing."""
        if not self.visible:
            self.toggle_reveal()
            self.visible.wait_for(True)

    def toggle_reveal(self, tap_delay=0.1):
        """Tap the 'Alt' key to toggle the hud visibility."""
        old_state = self.visible
        self.keybinding("hud/reveal", tap_delay)
        self.visible.wait_for(not old_state)

    def get_embedded_icon(self):
        """Returns the HUD view embedded icon or None if is not shown."""
        view = self.view
        if (not view):
          return None

        icons = view.get_children_by_type(HudEmbeddedIcon)
        return icons[0] if icons else None

    def get_launcher_icon(self):
        """Returns the HUD launcher icon"""
        unity = self.get_root_instance()
        icons = unity.select_many(HudLauncherIcon)
        assert(len(icons) == 1)
        return icons[0]

    @property
    def icon(self):
        if self.is_locked_launcher:
            return self.get_launcher_icon()
        else:
            return self.get_embedded_icon()

    @property
    def view(self):
        """Returns the HudView."""
        return self.get_hud_view()

    @property
    def searchbar(self):
        """Returns the searchbar attached to the hud."""
        return self.get_hud_view().searchbar

    @property
    def search_string(self):
        """Returns the searchbars' search string."""
        return self.searchbar.search_string

    @property
    def is_locked_launcher(self):
        return self.locked_to_launcher

    @property
    def monitor(self):
        return self.hud_monitor

    @property
    def geometry(self):
        return self.globalRect

    @property
    def selected_button(self):
        view = self.get_hud_view()
        if view:
            return view.selected_button
        else:
            return 0

    @property
    def hud_buttons(self):
        """Returns a list of current HUD buttons."""
        return self.view.hud_buttons

    @property
    def selected_hud_button(self):
        try:
            if len(self.hud_buttons) is 0:
                return 0
            [button] = filter(lambda x: x.focused, self.hud_buttons)
            return button
        except IndexError:
            raise RuntimeError("No HUD buttons found, is hud active?")
        except StateNotFoundError:
            log.warning("StateNotFoundError has been raised by HudController")
            return 0

    @property
    def num_buttons(self):
        view = self.get_hud_view()
        if view:
            return view.num_buttons
        else:
            return 0


class HudView(UnityIntrospectionObject):
    """Proxy object for the hud view child of the controller."""

    @property
    def searchbar(self):
        """Get the search bar attached to this hud view."""
        return self.get_children_by_type(SearchBar)[0]

    @property
    def hud_buttons(self):
        return self.get_children_by_type(HudButton)

    @property
    def geometry(self):
        return self.globalRect


class HudButton(UnityIntrospectionObject):
    """Proxy object for the hud buttons."""

    @property
    def label_no_formatting(self):
        """Returns the label text with the formatting removed."""
        htmlparser = HTMLParser()
        return htmlparser.unescape(re.sub("<[^>]*>", "", self.label))