From 3a7f3aee6ee9f52c245505c8d0d09c0ea91eb3a9 Mon Sep 17 00:00:00 2001 From: Hellow Date: Fri, 10 Mar 2023 11:09:05 +0100 Subject: [PATCH] flow chart --- README.md | 27 +++++++++++++++++++------- src/music_kraken/objects/collection.py | 5 ++++- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 5f8c11f..5dece24 100644 --- a/README.md +++ b/README.md @@ -306,15 +306,28 @@ flowchart TD exist(""" Check if music_object already exists.
-Gets all indexing values with music_object.indices. -If any returned value exists in Collection.object_map, +Gets all indexing values with music_object.indexing_values. +If any returned value exists in Collection._attribute_to_object_map, the music_object exists """) - subgraph merge["Merge the object with the already existing one."] + subgraph merge["Merging"] + + _merge("""merges the passed in object in the already + existing whith existing.merge(new)""") + + _map("""In case a new source or something simmilar + has been addet, it maps the existing object again. + """) + + return + + _merge --> _map --> return + end - subgraph add["Adding the object to the collection."] + subgraph add["Adding"] + end exist-->|"if it doesn't exist"|add @@ -329,9 +342,9 @@ the music_object exists #### Song -So as you can see, the probaply most important Class is the `music_kraken.Song` class. It is used to save the song in *(duh)*. +So as you can see, the probably most important Class is the `music_kraken.Song` class. It is used to save the song in *(duh)*. -It has handfull attributes, where half of em are self explanatory, like `title` or `genre`. The ones like `isrc` are only relevant to you, if you know what it is, so I won't elaborate on it. +It has handful attributes, where half of em are self-explanatory, like `title` or `genre`. The ones like `isrc` are only relevant to you, if you know what it is, so I won't elaborate on it. Interesting is the `date`. It uses a custom class. More on that [here](#music_krakenid3timestamp). @@ -341,7 +354,7 @@ For multiple Reasons I don't use the default `datetime.datetime` class. The most important reason is, that you need to pass in at least year, month and day. For every other values there are default values, that are indistinguishable from values that are directly passed in. But I need optional values. The ID3 standart allows default values. Additionally `datetime.datetime` is immutable, thus I can't inherint all the methods. Sorry. -Anyways you can create those custom objects easily. +Anyway you can create those custom objects easily. ```python from music_kraken import ID3Timestamp diff --git a/src/music_kraken/objects/collection.py b/src/music_kraken/objects/collection.py index 9012f45..bb5b449 100644 --- a/src/music_kraken/objects/collection.py +++ b/src/music_kraken/objects/collection.py @@ -59,7 +59,10 @@ class Collection: if value in self._attribute_to_object_map[name]: # if the object does already exist # thus merging and don't add it afterwards - self._attribute_to_object_map[name][value].merge(element) + existing_object = self._attribute_to_object_map[name][value] + existing_object.merge(element) + # in case any relevant data has been added (e.g. it remaps the old object) + self.map_element(existing_object) return self._data.append(element)