lino.mixins.human

See test cases and examples in The Human mixin.

(This module's source code is available here.)

Functions

get_salutation(gender[, nominative])

Returns "Mr" or "Mrs" or a translation thereof, depending on the gender and the current language.

name2kw(s[, last_name_first])

Separate first name from last name.

parse_name(text)

Parse the given text and return a dict of first_name and last_name value.

strip_name_prefix(s)

Strip name prefix from given family name s.

upper1(s)

Classes

Born(*args, **kwargs)

Abstract base class that adds a birth_date field and a virtual field "Age".

Human(*args, **kwargs)

Base class for models that represent a human.

lino.mixins.human.strip_name_prefix(s)

Strip name prefix from given family name s.

lino.mixins.human.name2kw(s, last_name_first=True)

Separate first name from last name. Split a string that contains both last_name and first_name. The caller must indicate whether the string contains last_name first (e.g. Saffre Luc) or first_name first (e.g. Luc Saffre).

lino.mixins.human.parse_name(text)

Parse the given text and return a dict of first_name and last_name value.

Extends name2kw() by raising a ValidationError if necessary and by capitalizing each part of the name.

lino.mixins.human.get_salutation(gender, nominative=False)

Returns "Mr" or "Mrs" or a translation thereof, depending on the gender and the current language.

Note that the English abbreviations Mr and Mrs are written either with (AE) or without (BE) a dot.

The optional keyword argument nominative is used only in certain languages like German: specifying nominative=True for a male person will return the nominative or direct form "Herr" instead of the default (accusative or indirect form) "Herrn".

class lino.mixins.human.Human(*args, **kwargs)

Bases: lino.core.model.Model

Base class for models that represent a human.

title

Used to specify a professional position or academic qualification like "Dr." or "PhD".

If given, the content of this field comes always between salutation and name.

first_name

The first name, also known as given name.

last_name

The last name, also known as family name.

middle_name

A space-separated list of all middle names.

gender

The sex of this person (male or female).

Possible values are defined in lino.modlib.lino.choicelists.Genders.

mf(m, f, u=None)

Taking three parameters m, f and u of any type, returns one of them depending on whether this Person is male, female or of unknown gender.

See The Human mixin for some examples.

get_last_name_prefix()

May be used for handling special of titles (e.g. "Cardinal", "Graf") which come before the last name (not before the first name).

Lino currently does not support titles which replace the salutation ("Br.", "Sr.") or which must come at another position of the full name

External links: linguee.de and wikipedia.org

get_full_name(salutation=True, upper=None, **salutation_options)

Returns a one-line string composed of salutation, first_name and last_name.

The optional keyword argument salutation can be set to False to suppress salutations.

The optional keyword argument upper can be specified to override the Site's default value (lino.core.site.Site.uppercase_last_name). True means to convert the last name to uppercase as is usually done in French.

Any other keyword arguments are forwarded to lino.mixins.human.get_salutation() (see there).

If get_after_salutation_words() yields a sequence of words, then these are inserted between salutation and first name.

See The Human mixin for some examples.

property full_name

Returns a one-line string composed of salutation, first_name and last_name.

The optional keyword argument salutation can be set to False to suppress salutations.

The optional keyword argument upper can be specified to override the Site's default value (lino.core.site.Site.uppercase_last_name). True means to convert the last name to uppercase as is usually done in French.

Any other keyword arguments are forwarded to lino.mixins.human.get_salutation() (see there).

If get_after_salutation_words() yields a sequence of words, then these are inserted between salutation and first name.

See The Human mixin for some examples.

format_family_member(ar, other)

Used in humanlinks.LinksByHuman and in households.SiblingsByPerson.

class lino.mixins.human.Born(*args, **kwargs)

Bases: lino.core.model.Model

Abstract base class that adds a birth_date field and a virtual field "Age".

birth_date

An IncompleteDateField.

age

Virtual field displaying the age in years.

get_age(today=None)

Return the age (in years) of this human. See lino.utils.IncompleteDateField.get_age().

get_exact_age(today=None)

Return the age as a datetime.timedelta object.

Optional keyword argument today should be a datetime.date instance to replace the actual current date. This is used if you want the age at a given date in the past or the future. The default value calls dd.Site.today().