|
@ -1,4 +1,5 @@ |
|
|
import MySQLdb |
|
|
import MySQLdb |
|
|
|
|
|
import hashlib |
|
|
|
|
|
|
|
|
from .member import Member as member |
|
|
from .member import Member as member |
|
|
from .group import Group as group |
|
|
from .group import Group as group |
|
@ -9,7 +10,7 @@ from dateutil.relativedelta import relativedelta |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Admidio: |
|
|
class Admidio: |
|
|
"""Creates the Admidio Class""" |
|
|
|
|
|
|
|
|
"""Admidio Class""" |
|
|
|
|
|
|
|
|
def __init__(self, mysql_host, mysql_user, mysql_pass, mysql_db, |
|
|
def __init__(self, mysql_host, mysql_user, mysql_pass, mysql_db, |
|
|
db_prefix): |
|
|
db_prefix): |
|
@ -48,6 +49,20 @@ class Admidio: |
|
|
def __del__(self): |
|
|
def __del__(self): |
|
|
pass |
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
def __eq__(self, other): |
|
|
|
|
|
if isinstance(other, Admidio): |
|
|
|
|
|
return self.hash() == other.hash() |
|
|
|
|
|
|
|
|
|
|
|
def hash(self): |
|
|
|
|
|
s = '' |
|
|
|
|
|
for _, x in self.members.items(): |
|
|
|
|
|
s += x.hash() |
|
|
|
|
|
for _, x in self.groups.items(): |
|
|
|
|
|
s += x.hash() |
|
|
|
|
|
for _, x in self.events.items(): |
|
|
|
|
|
s += x.hash() |
|
|
|
|
|
return hashlib.md5(s.encode('utf-8')).hexdigest() |
|
|
|
|
|
|
|
|
def connect_db(self): |
|
|
def connect_db(self): |
|
|
self.db = MySQLdb.connect( |
|
|
self.db = MySQLdb.connect( |
|
|
host=self.mysql_host, |
|
|
host=self.mysql_host, |
|
|