/usr/lib/python2.7/dist-packages/autopilot/input/_common.py is in python-autopilot 1.4.1+17.04.20170305-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 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
#
# Autopilot Functional Test Tool
# Copyright (C) 2012-2013 Canonical
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""Common, private utility code for input emulators."""
import logging
_logger = logging.getLogger(__name__)
def get_center_point(object_proxy):
"""Get the center point of an object.
It searches for several different ways of determining exactly where the
center is.
:raises ValueError: if `object_proxy` has the globalRect attribute but it
is not of the correct type.
:raises ValueError: if `object_proxy` doesn't have the globalRect
attribute, it has the x and y attributes instead, but they are not of
the correct type.
:raises ValueError: if `object_proxy` doesn't have any recognised position
attributes.
"""
try:
x, y, w, h = object_proxy.globalRect
_logger.debug("Moving to object's globalRect coordinates.")
return x+w/2, y+h/2
except AttributeError:
pass
except (TypeError, ValueError):
raise ValueError(
"Object '%r' has globalRect attribute, but it is not of the "
"correct type" % object_proxy)
try:
x, y = object_proxy.center_x, object_proxy.center_y
_logger.debug("Moving to object's center_x, center_y coordinates.")
return x, y
except AttributeError:
pass
try:
x, y, w, h = (
object_proxy.x, object_proxy.y, object_proxy.w, object_proxy.h)
_logger.debug(
"Moving to object's center point calculated from x,y,w,h "
"attributes.")
return x+w/2, y+h/2
except AttributeError:
raise ValueError(
"Object '%r' does not have any recognised position attributes" %
object_proxy)
except (TypeError, ValueError):
raise ValueError(
"Object '%r' has x,y attribute, but they are not of the correct "
"type" % object_proxy)
|