Table Of Contents

Previous topic

humphrey.core.movie

This Page

humphrey.core.person

This module contains the classes regarding persons involved in the production of movies, such as directors and cast members.

Every person has a name which must be specified on initialization. The name may not be empty and may not consist only of whitespace.

It is possible -and recommended- to store the IMDb ids of persons. The IMDb id is a 7-digit string and it will be used as the primary value to identify a person. Two persons are considered the same if they have the same IMDb id, regardless of their names:

>>> p1 = Person(u"Farrah Fawcett", imdb_id=u'0000396')
>>> p2 = Person(u"Farrah Fawcett-Majors", imdb_id=u'0000396')
>>> p1 == p2
True

If they have no IMDb ids, their names will be checked. A comparison between a person and a name is also valid:

>>> p = Person(u"Marlon Brando")
>>> p == u"Marlon Brando"
True

Roles

Persons can take on directing and acting roles in movies. These roles are represented by classes which wrap person objects. The Director class is for directing roles and the CastMember class is for acting roles.

A role object contains Role.movie and Role.person attributes to provide the connection between the movie and the person. There is also a Role.position attribute which is used for ordering the list of persons having that role.

Role objects must be initialized with the person object they will wrap and can be checked for equality against the person they wrap:

>>> p = Person(u"Marlon Brando")
>>> c = CastMember(p)
>>> c == p
True

The movies in which a person is a director or a cast member can be accessed via the Person.directed and Person.acted attributes, respectively. Both these attributes are lists of CastMember objects:

for role in person.acted:
    print role.movie.title
    print role.position

API

class humphrey.core.person.Person(name, imdb_id=None)

Base class for persons in movies.

acted
(list of humphrey.core.person.CastMember) Acting roles of this person.
asXML()
Return an XML representation of the person.
directed
(list of humphrey.core.person.Director) Directing roles of this person.
get_imdb_id()
Return the IMDb id of the person.
get_name()
Return the name of the person.
imdb_id
(unicode) IMDb id of the person.
name
(unicode) Name of the person.
set_imdb_id(imdb_id)

Set the IMDb id of the person.

Parameter:imdb_id (unicode | str | int | long) – New IMDb id value to set. If a number or a string, it will be converted to unicode.
Raises ValueError:
 If the IMDb id is invalid.
set_name(name)

Set the name of the person.

Parameter:name (unicode) – New name value to set. It will be stripped of leading and trailing whitespace. If empty, it will be regarded as unspecified.
Raises ValueError:
 If the name of the person is not specified.
class humphrey.core.person.Role(person)

A director or cast member of a movie.

Parameter:person (humphrey.core.person.Person) – Person playing this role.
movie
(humphrey.core.movie.Movie) Movie which contains this role.
person
(humphrey.core.person.Person) Person who played this role.
position
(int) Position in which this person will be listed in the role list.
reset_position()
Reset the position of this person in the role list.
class humphrey.core.person.Director(person)

Bases: humphrey.core.person.Role

A director of a movie.

Parameter:person (humphrey.core.person.Person) – Person playing this role.
class humphrey.core.person.CastMember(person)

Bases: humphrey.core.person.Role

An actor or an actress in a movie.

Parameter:person (humphrey.core.person.Person) – Person playing this role.