Update objects.md
This commit is contained in:
parent
ac7ab7b0ce
commit
49ad1d1689
@ -4,13 +4,28 @@
|
|||||||
|
|
||||||
[music_kraken.objects.DatabaseObject](../src/music_kraken/objects/parents.py)
|
[music_kraken.objects.DatabaseObject](../src/music_kraken/objects/parents.py)
|
||||||
|
|
||||||
|
This is a parent object, which most Music-Objects inherit from. It provides the **functionality** to:
|
||||||
|
|
||||||
|
- autogenerate id's *(UUID)*, if not passed in the constructur.
|
||||||
|
- [merge](#databaseobjectmerge) the data of another instance of the same time in self.
|
||||||
|
- Check if two different instances of the same type represent the same data, using `__eq__`.
|
||||||
|
|
||||||
|
Additionally it provides an **Interface** to:
|
||||||
|
|
||||||
|
- define the attributes used to [merge](#databaseobjectmerge).
|
||||||
|
- define the attribuse and values used to check for equal data. *(used in `__eq__` and in the merge)*
|
||||||
|
- get the id3 [metadata](#metadata).
|
||||||
|
- get all [options](#options) *(used in searching from e.g. the command line)*
|
||||||
|
|
||||||
|
### DatabaseObject.merge()
|
||||||
|
|
||||||
## Collection
|
## Collection
|
||||||
|
|
||||||
[music_kraken.objects.Collection](../src/music_kraken/objects/collection.py)
|
[music_kraken.objects.Collection](../src/music_kraken/objects/collection.py)
|
||||||
|
|
||||||
This is an object, which acts as a list. You can save instaces of a subclass of [DatabaseObject](#databaseobject).
|
This is an object, which acts as a list. You can save instaces of a subclass of [DatabaseObject](#databaseobject).
|
||||||
|
|
||||||
Then you can for example append a new Object. The difference to a normal list is, that if you have two different objects that both represent the same data, it doesn't get added, but all data gets merged into one Object instead.
|
Then you can for example append a new Object. The difference to a normal list is, that if you have two different objects that both represent the same data, it doesn't get added, but all data gets [merged](#databaseobjectmerge) into the existing Object instead.
|
||||||
|
|
||||||
For example, you have two different Artist-Objects, where both have one source in common. The one Artist-Object already is in the Collection. The other artist object is passed in the append command.
|
For example, you have two different Artist-Objects, where both have one source in common. The one Artist-Object already is in the Collection. The other artist object is passed in the append command.
|
||||||
In this case it doesn't simply add the artist object to the collection, but modifies the already existing Artist-Object, adding all attributes the new artist object has, and then discards the other object.
|
In this case it doesn't simply add the artist object to the collection, but modifies the already existing Artist-Object, adding all attributes the new artist object has, and then discards the other object.
|
||||||
@ -34,3 +49,7 @@ Function | Explanation
|
|||||||
`shallow_list` | gets a shallow copy of the list `_data` the objects are contained in
|
`shallow_list` | gets a shallow copy of the list `_data` the objects are contained in
|
||||||
`sort()` | takes the same arguments than `list.sort`, and does the same
|
`sort()` | takes the same arguments than `list.sort`, and does the same
|
||||||
`__iter__()` | allows you to use collections e.g. a for loop
|
`__iter__()` | allows you to use collections e.g. a for loop
|
||||||
|
|
||||||
|
## Options
|
||||||
|
|
||||||
|
## Metadata
|
||||||
|
Loading…
Reference in New Issue
Block a user