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:
parent
e318194274
commit
670d50cefd
3 changed files with 55 additions and 50 deletions
10
mcg/utils.py
10
mcg/utils.py
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue