Implement __hash__ method for custom classes (close #45)

Implement a reasonable __hash__ method() for the classes MCGAlbum and
MCGTrack and use a separate id for referencing albums.
This commit is contained in:
coderkun 2018-11-04 17:44:52 +01:00
commit 670d50cefd
3 changed files with 55 additions and 50 deletions

View file

@ -3,6 +3,7 @@
import gi
gi.require_version('Gtk', '3.0')
import hashlib
import locale
import os
import urllib
@ -75,6 +76,15 @@ class Utils:
return title
def generate_id(values):
if type(values) is not list:
values = [values]
m = hashlib.md5()
for value in values:
m.update(value.encode('utf-8'))
return m.hexdigest()
class SortOrder: