/usr/share/gps/plug-ins/GPS_help.py is in gnat-gps-common 5.3dfsg-1.
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 | """ This plugin provides interactive help for the GPS API using the
"help" command in the Python and Shell consoles.
"""
import inspect
import GPS
default_help = help
def helpdoc (gps_class_name):
import GPS_doc
items = gps_class_name.split('.')
parent = GPS_doc
for item in items:
if hasattr(parent, item):
parent = getattr(parent, item)
return parent.__doc__
# no class found
return "Could not find documentation for GPS class %s" % gps_class_name
def help(item):
# If this item belongs to the GPS module, extract its documentation
# from the module GPS_doc
if inspect.getmodule(item) == GPS:
class_name = None
if inspect.isclass(item):
class_name = item.__name__
elif inspect.isclass(item):
class_name = item.__class__.__name__
else:
# item might be a method of a class. No choice here but to iterate
# over all classes in GPS and attempt to find the parent.
item_name = item.__name__
for class_name in dir(GPS):
klass = getattr(GPS, class_name)
if inspect.isclass(klass):
if (hasattr(klass, item_name)
and getattr(klass, item_name) == item):
class_name = klass.__name__ + '.' + item_name
break
if class_name:
print helpdoc(class_name)
return
# fallback on the default help function
default_help(item)
|