Collectionο
The fundamental core collection classes for the entire package.
Classes:
|
Abstract base class for strategies relating to __getitem__ operations on a |
|
Get an item via its name for a |
|
Get an item via its path for a |
|
Get an item via its remote ID for a |
|
Get an item via its remote URI for a |
|
Get an item via its remote API URL for a |
|
Get an item via its remote external URL for a |
Generic class for storing a collection of musify items. |
- class musify.libraries.core.collection.ItemGetterStrategy(key)ο
Bases:
GenericAbstract base class for strategies relating to __getitem__ operations on a
MusifyCollectionAttributes:
The name to assign to this ItemGetter when logging
Methods:
get_value_from_item(item)Retrieve the appropriate value from a given
itemfor this ItemGetter typeget_item(collection)Run this strategy and return the matched item from the given
collection-
key:
TypeVar(KT)ο
- abstract property name: strο
The name to assign to this ItemGetter when logging
- abstractmethod get_value_from_item(item)ο
Retrieve the appropriate value from a given
itemfor this ItemGetter type- Return type:
KT
- get_item(collection)ο
Run this strategy and return the matched item from the given
collection- Return type:
TypeVar(IT)
-
key:
- class musify.libraries.core.collection.NameGetter(key)ο
Bases:
ItemGetterStrategyGet an item via its name for a
MusifyCollectionAttributes:
The name to assign to this ItemGetter when logging
Methods:
get_value_from_item(item)Retrieve the appropriate value from a given
itemfor this ItemGetter type- property name: strο
The name to assign to this ItemGetter when logging
- get_value_from_item(item)ο
Retrieve the appropriate value from a given
itemfor this ItemGetter type- Return type:
str
- class musify.libraries.core.collection.PathGetter(key)ο
Bases:
ItemGetterStrategyGet an item via its path for a
MusifyCollectionAttributes:
The name to assign to this ItemGetter when logging
Methods:
get_value_from_item(item)Retrieve the appropriate value from a given
itemfor this ItemGetter type- property name: strο
The name to assign to this ItemGetter when logging
- get_value_from_item(item)ο
Retrieve the appropriate value from a given
itemfor this ItemGetter type- Return type:
Path
- class musify.libraries.core.collection.RemoteIDGetter(key)ο
Bases:
ItemGetterStrategyGet an item via its remote ID for a
MusifyCollectionAttributes:
The name to assign to this ItemGetter when logging
Methods:
get_value_from_item(item)Retrieve the appropriate value from a given
itemfor this ItemGetter type- property name: strο
The name to assign to this ItemGetter when logging
- get_value_from_item(item)ο
Retrieve the appropriate value from a given
itemfor this ItemGetter type- Return type:
str
- class musify.libraries.core.collection.RemoteURIGetter(key)ο
Bases:
ItemGetterStrategyGet an item via its remote URI for a
MusifyCollectionAttributes:
The name to assign to this ItemGetter when logging
Methods:
get_value_from_item(item)Retrieve the appropriate value from a given
itemfor this ItemGetter type- property name: strο
The name to assign to this ItemGetter when logging
- get_value_from_item(item)ο
Retrieve the appropriate value from a given
itemfor this ItemGetter type- Return type:
str
- class musify.libraries.core.collection.RemoteURLAPIGetter(key)ο
Bases:
ItemGetterStrategyGet an item via its remote API URL for a
MusifyCollectionAttributes:
The name to assign to this ItemGetter when logging
Methods:
get_value_from_item(item)Retrieve the appropriate value from a given
itemfor this ItemGetter type- property name: strο
The name to assign to this ItemGetter when logging
- get_value_from_item(item)ο
Retrieve the appropriate value from a given
itemfor this ItemGetter type- Return type:
URL
- class musify.libraries.core.collection.RemoteURLEXTGetter(key)ο
Bases:
ItemGetterStrategyGet an item via its remote external URL for a
MusifyCollectionAttributes:
The name to assign to this ItemGetter when logging
Methods:
get_value_from_item(item)Retrieve the appropriate value from a given
itemfor this ItemGetter type- property name: strο
The name to assign to this ItemGetter when logging
- get_value_from_item(item)ο
Retrieve the appropriate value from a given
itemfor this ItemGetter type- Return type:
URL
- class musify.libraries.core.collection.MusifyCollectionο
Bases:
MusifyObject,MutableSequence,HasLength,GenericGeneric class for storing a collection of musify items.
Attributes:
The items in this collection
Total duration of all items in this collection in seconds
Methods:
count(_MusifyCollection__item)Return the number of occurrences of the given
MusifyItemin this collectionindex(_MusifyCollection__item[,Β ...])Return first index of item from items in this collection.
copy()Return a shallow copy of the list of items in this collection
append(_MusifyCollection__item[,Β ...])Append one item to the items in this collection
extend(_MusifyCollection__items[,Β ...])Append many items to the items in this collection
insert(_MusifyCollection__index,Β ...[,Β ...])Insert given
MusifyItembefore the given indexremove(_MusifyCollection__item)Remove one item from the items in this collection
pop([_MusifyCollection__item])Remove one item from the items in this collection and return it
reverse()Reverse the order of items in this collection in-place
clear()Remove all items from this collection
sort([fields,Β shuffle_mode,Β shuffle_weight,Β ...])Sort items in this collection in-place based on given conditions.
intersection(other)Return the intersection between the items in this collection and an
othercollection as a new list.difference(other)Return the difference between the items in this collection and an
othercollection as a new list.outer_difference(other)Return the outer difference between the items in this collection and an
othercollection as a new list.as_dict()Return a dictionary representation of the key attributes of this object.
- abstract property items: list[T]ο
The items in this collection
- abstract property length: float | Noneο
Total duration of all items in this collection in seconds
- count(_MusifyCollection__item)ο
Return the number of occurrences of the given
MusifyItemin this collection- Return type:
int
- index(_MusifyCollection__item, _MusifyCollection__start=None, _MusifyCollection__stop=None)ο
Return first index of item from items in this collection.
- Raises:
ValueError β If the value is not present.
MusifyTypeError β If given item does not match the item type of this collection.
- Return type:
int
- copy()ο
Return a shallow copy of the list of items in this collection
- Return type:
list[T]
- append(_MusifyCollection__item, allow_duplicates=True)ο
Append one item to the items in this collection
- Return type:
None
- extend(_MusifyCollection__items, allow_duplicates=True)ο
Append many items to the items in this collection
- Return type:
None
- insert(_MusifyCollection__index, _MusifyCollection__item, allow_duplicates=True)ο
Insert given
MusifyItembefore the given index- Return type:
None
- remove(_MusifyCollection__item)ο
Remove one item from the items in this collection
- Return type:
None
- pop(_MusifyCollection__item=None)ο
Remove one item from the items in this collection and return it
- Return type:
T
- reverse()ο
Reverse the order of items in this collection in-place
- Return type:
None
- clear()ο
Remove all items from this collection
- Return type:
None
- sort(fields=(), shuffle_mode=None, shuffle_weight=1.0, key=None, reverse=False)ο
Sort items in this collection in-place based on given conditions. If key is given,
- Parameters:
fields (
GenericAlias[Field|None] |Mapping[Field|None,bool] (default:())) βWhen None and ShuffleMode is RANDOM, shuffle the tracks. Otherwise, do nothing.
List of tags/properties to sort by.
Map of {<tag/property>: <reversed>}. If reversed is true, sort the
tag/propertyin reverse.
shuffle_mode (
ShuffleMode|None(default:None)) β The mode to use for shuffling.shuffle_weight (
float(default:1.0)) β The weights (between 0 and 1) to apply to shuffling modes that can use it. This value will automatically be limited to within the accepted range 0 and 1.key (
Field|None(default:None)) β Tag or property to sort on. Can be given instead offieldsfor a simple sort. If set, all other fields apart fromreverseare ignored. If None,fields,shuffle_mode,shuffle_by, andshuffle_weightare used to apply sorting.reverse (
bool(default:False)) β If true, reverse the order of the sort at the end.
- Return type:
None
- intersection(other)ο
Return the intersection between the items in this collection and an
othercollection as a new list.(i.e. all items that are in both this collection and the
othercollection).- Return type:
list[T]
- difference(other)ο
Return the difference between the items in this collection and an
othercollection as a new list.(i.e. all items that are in this collection but not the
othercollection).- Return type:
list[T]
- outer_difference(other)ο
Return the outer difference between the items in this collection and an
othercollection as a new list.(i.e. all items that are in the
othercollection but not in this collection).- Return type:
list[T]
- as_dict()ο
Return a dictionary representation of the key attributes of this object.
- The results of this function are used to produce the following:
A JSON representation of the object when calling
json()The string representation of the object when calling str() on the object
The representation of the object when calling repr() on the object