/usr/share/pyshared/lpltk/person.py is in python-launchpadlib-toolkit 2.3.
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 | #!/usr/bin/python
from utils import (
o2str,
typecheck_Entry
)
# Person
#
# A class that provides a convenient interface to a Launchpad person.
# (as returned from a call to the bug.owner property)
#
class Person(object):
# __init__
#
# Initialize the Person instance from a Launchpad bug.
#
def __init__(self, tkbug, lpperson, service=None):
if not tkbug is None:
self.__commit_changes = tkbug.commit_changes
self.__tkbug = tkbug
self.__person = typecheck_Entry(lpperson)
self.__service = service
self.__username = None
self.__full_name = None
self.__karma = None
self.__email_addresses = None
def __eq__(self, other):
if other is None:
return self.__person is None
return self.__person == other.__person
def __ne__(self, other):
if other is None:
return not self.__person is None
return self.__person != other.__person
#--------------------------------------------------------------------------
# username
#
@property
def username(self):
if self.__username is None:
self.__username = self.lpperson.name
return self.__username
#--------------------------------------------------------------------------
# display_name
#
@property
def display_name(self):
return self.full_name
#--------------------------------------------------------------------------
# full_name
#
@property
def full_name(self):
if self.__full_name is None:
self.__full_name = o2str(self.__person.display_name)
return self.__full_name
#--------------------------------------------------------------------------
# first_name
#
@property
def first_name(self):
if self.__full_name is None:
self.__full_name = o2str(self.__person.display_name)
return self.__full_name.split(' ')[0]
#--------------------------------------------------------------------------
# email_addresses - list of confirmed email addresses, if not hidden
#
@property
def email_addresses(self):
if self.__person is None:
return None
if self.__email_addresses is None:
self.__email_addresses = []
if not self.__person.hide_email_addresses:
for email_obj in self.__person.confirmed_email_addresses:
self.__email_addresses.append(email_obj.email)
return self.__email_addresses
#--------------------------------------------------------------------------
# karma
#
@property
def karma(self):
if self.__karma is None:
self.__karma = self.__person.karma
return self.__karma
#--------------------------------------------------------------------------
# lpperson
#
@property
def lpperson(self):
return self.__person
#--------------------------------------------------------------------------
# subscribed_packages - Returns a list of source packages the team is
# subscribed to
#
@property
def subscribed_packages(self):
from distribution_source_package import DistributionSourcePackage
for pkg in self.__person.getBugSubscriberPackages():
yield DistributionSourcePackage(self.__service, pkg)
#--------------------------------------------------------------------------
# subscribed_package_names - Returns a list of strings corresponding to
# source packages that the person (team) is subscribed to.
#
@property
def subscribed_package_names(self):
for pkg in self.subscribed_packages:
yield pkg.display_name.split(' ')[0]
#--------------------------------------------------------------------------
# teams - Returns a list of names of teams this person belongs to.
#
@property
def super_teams(self):
teams = []
for team in self.__person.super_teams:
teams.append(o2str(team.name))
return teams
# ------------------------------------------------------------------------
# uri - The self_link for the person
@property
def uri(self):
return self.__person.self_link
# vi:set ts=4 sw=4 expandtab:
|