From 85c38ea7d577bbe5f9e0ce075f13ea06f1e24872 Mon Sep 17 00:00:00 2001 From: Hellow2 Date: Mon, 13 Mar 2023 13:58:24 +0100 Subject: [PATCH] continued documentation --- README.md | 49 ++++------------------------------------ documentation/objects.md | 27 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index dff4049..5213a74 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,7 @@ This application is $100\%$ centered around Data. Thus the most important thing - explanation of the [Data Model](#data-model) - how to use the [Data Objects](#data-objects) +- further Dokumentation of *hopefully* [most relevant classes](documentation/objects.md) ```mermaid --- @@ -295,8 +296,7 @@ For those who don't want any bugs and use it as intended *(which is recommended, If you want to append for example a Song to an Album, you obviously need to check beforehand if the Song already exists in the Album, and if so, you need to merge their data in one Song object, to not loose any Information. -Fortunately I implemented all of this functionality in [objects.Collection](#collection).append(music_object). -I made a flow chart showing how it works: +This is how I solve this problem: ```mermaid --- @@ -341,9 +341,9 @@ the music_object exists exist-->|"if already exists"|merge --> return ``` -This is Implemented in [music_kraken.objects.Collection.append()](src/music_kraken/objects/collection.py). +This is Implemented in [music_kraken.objects.Collection.append()](documentation/objects.md#collection). The merging which is mentioned in the flowchart is explained in the documentation of [DatabaseObject.merge()](documentation/objects.md#databaseobjectmerge). -The indexing values are defined in the superclass [DatabaseObject](src/music_kraken/objects/parents.py) and get implemented for each Object seperately. I will just give as example its implementation for the `Song` class: +The indexing values are defined in the superclass [DatabaseObject](documentation/objects.md#databaseobject) and get implemented for each Object seperately. I will just give as example its implementation for the `Song` class: ```python @property @@ -355,48 +355,7 @@ def indexing_values(self) -> List[Tuple[str, object]]: *[('url', source.url) for source in self.source_collection] ] ``` - -## Classes and Objects -### music_kraken.objects - -#### Collection - -#### Song - -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 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). - -#### ID3Timestamp - -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. - -Anyway you can create those custom objects easily. - -```python -from music_kraken import ID3Timestamp - -# returns an instance of ID3Timestamp with the current time -ID3Timestamp.now() - -# yea -ID3Timestamp(year=1986, month=3, day=1) -``` - -you can pass in the Arguments: - - year - - month - - day - - hour - - minute - - second - -:) # Old implementation diff --git a/documentation/objects.md b/documentation/objects.md index 6aa27ed..d712a85 100644 --- a/documentation/objects.md +++ b/documentation/objects.md @@ -53,3 +53,30 @@ Function | Explanation ## Options ## Metadata + +## Song + +This object inherits from [DatabaseObject](#databaseobject) and implements all its interfaces. + +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). + +## ID3Timestamp + +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. + +Anyway you can create those custom objects easily. + +```python +from music_kraken import ID3Timestamp + +# returns an instance of ID3Timestamp with the current time +ID3Timestamp.now() + +# returns an instance of ID3Timestamp with the given values +# all values are optional if unknown +ID3Timestamp(year=1986, month=3, day=1, hour=12, minute=30, second=6) +```