calliope.utils

Utility functions for resolving items

Module Contents

Classes

FeatMode

Generic enumeration.

Functions

normalize_creator_title(creator, title[, feat_mode])

Remove featuring artists from title and append them to the artist string

drop_none_values(dct)

Delete all fields with None value from dct.

parse_sort_date(date_str)

Parse a potentially incomplete date string of the format YYYY-MM-DD and

get_nested(sequence, keys)

Get the value from a nested dict/list data structure, returning None if one

get_isrcs(el)

Find the ISRCs of item and return them as list

class calliope.utils.FeatMode

Bases: enum.Enum

Generic enumeration.

Derive from this class to define new enumerations.

KEEP
DROP
TO_CREATOR
TO_TITLE
calliope.utils.normalize_creator_title(creator, title, feat_mode=FeatMode.TO_CREATOR)

Remove featuring artists from title and append them to the artist string

Parameters
  • creator (Optional[str]) –

  • title (Optional[str]) –

Return type

Tuple[Optional[str], Optional[str]]

calliope.utils.drop_none_values(dct)

Delete all fields with None value from dct.

Parameters

dct (calliope.playlist.Item) –

Return type

calliope.playlist.Item

calliope.utils.parse_sort_date(date_str)

Parse a potentially incomplete date string of the format YYYY-MM-DD and return a datetime.date object with conservative defaults for missing data.

Parameters

date_str (Optional[str]) –

Return type

Optional[datetime.date]

calliope.utils.get_nested(sequence, keys)

Get the value from a nested dict/list data structure, returning None if one of the keys is invalid.

Parameters
  • sequence (Dict) –

  • keys (Iterable) –

calliope.utils.get_isrcs(el)

Find the ISRCs of item and return them as list