Fix ident and code cleaning
This commit is contained in:
parent
8dbb067996
commit
3c2da7f85e
4 changed files with 483 additions and 483 deletions
258
HashMap.py
258
HashMap.py
|
@ -5,38 +5,38 @@
|
||||||
#
|
#
|
||||||
# Mapping configuration
|
# Mapping configuration
|
||||||
# {
|
# {
|
||||||
# '[dst key 1]': { # Key name in the result
|
# '[dst key 1]': { # Key name in the result
|
||||||
#
|
#
|
||||||
# 'order': [int], # Processing order between destinations keys
|
# 'order': [int], # Processing order between destinations keys
|
||||||
#
|
#
|
||||||
# # Source values
|
# # Source values
|
||||||
# 'other_key': [key], # Other key of the destination to use as source of values
|
# 'other_key': [key], # Other key of the destination to use as source of values
|
||||||
# 'key' : '[src key]', # Key of source hash to get source values
|
# 'key' : '[src key]', # Key of source hash to get source values
|
||||||
# 'keys' : ['[sk1]', '[sk2]', ...], # List of source hash's keys to get source values
|
# 'keys' : ['[sk1]', '[sk2]', ...], # List of source hash's keys to get source values
|
||||||
#
|
#
|
||||||
# # Clean / convert values
|
# # Clean / convert values
|
||||||
# 'cleanRegex': '[regex]', # Regex that be use to remove unwanted characters. Ex : [^0-9+]
|
# 'cleanRegex': '[regex]', # Regex that be use to remove unwanted characters. Ex : [^0-9+]
|
||||||
# 'convert': [function], # Function to use to convert value : Original value will be passed
|
# 'convert': [function], # Function to use to convert value : Original value will be passed
|
||||||
# # as argument and the value retrieve will replace source value in
|
# # as argument and the value retrieve will replace source value in
|
||||||
# # the result
|
# # the result
|
||||||
# # Ex :
|
# # Ex :
|
||||||
# # lambda x: x.strip()
|
# # lambda x: x.strip()
|
||||||
# # lambda x: "myformat : %s" % x
|
# # lambda x: "myformat : %s" % x
|
||||||
# # Deduplicate / check values
|
# # Deduplicate / check values
|
||||||
# 'deduplicate': [bool], # If True, sources values will be depluplicated
|
# 'deduplicate': [bool], # If True, sources values will be depluplicated
|
||||||
# 'check': [function], # Function to use to check source value : Source value will be passed
|
# 'check': [function], # Function to use to check source value : Source value will be passed
|
||||||
# # as argument and if function return True, the value will be preserved
|
# # as argument and if function return True, the value will be preserved
|
||||||
# # Ex :
|
# # Ex :
|
||||||
# # lambda x: x in my_global_hash
|
# # lambda x: x in my_global_hash
|
||||||
# # Join values
|
# # Join values
|
||||||
# 'join': '[glue]', # If present, sources values will be join using the "glue"
|
# 'join': '[glue]', # If present, sources values will be join using the "glue"
|
||||||
#
|
#
|
||||||
# # Alternative mapping
|
# # Alternative mapping
|
||||||
# 'or': { [map configuration] } # If this mapping case does not retreive any value, try to get value(s)
|
# 'or': { [map configuration] } # If this mapping case does not retreive any value, try to get value(s)
|
||||||
# # with this other mapping configuration
|
# # with this other mapping configuration
|
||||||
# },
|
# },
|
||||||
# '[dst key 2]': {
|
# '[dst key 2]': {
|
||||||
# [...]
|
# [...]
|
||||||
# }
|
# }
|
||||||
# }
|
# }
|
||||||
#
|
#
|
||||||
|
@ -50,125 +50,125 @@
|
||||||
import logging, re
|
import logging, re
|
||||||
|
|
||||||
def clean_value(value):
|
def clean_value(value):
|
||||||
if isinstance(value, int):
|
if isinstance(value, int):
|
||||||
value=str(value)
|
value=str(value)
|
||||||
return value.encode('utf8')
|
return value.encode('utf8')
|
||||||
|
|
||||||
def map(map_keys,src,dst={}):
|
def map(map_keys,src,dst={}):
|
||||||
|
|
||||||
def get_values(dst_key,src,m):
|
def get_values(dst_key,src,m):
|
||||||
# Extract sources values
|
# Extract sources values
|
||||||
values=[]
|
values=[]
|
||||||
if 'other_key' in m:
|
if 'other_key' in m:
|
||||||
if m['other_key'] in dst:
|
if m['other_key'] in dst:
|
||||||
values=dst[m['other_key']]
|
values=dst[m['other_key']]
|
||||||
if 'key' in m:
|
if 'key' in m:
|
||||||
if m['key'] in src and src[m['key']]!='':
|
if m['key'] in src and src[m['key']]!='':
|
||||||
values.append(clean_value(src[m['key']]))
|
values.append(clean_value(src[m['key']]))
|
||||||
|
|
||||||
if 'keys' in m:
|
if 'keys' in m:
|
||||||
for key in m['keys']:
|
for key in m['keys']:
|
||||||
if key in src and src[key]!='':
|
if key in src and src[key]!='':
|
||||||
values.append(clean_value(src[key]))
|
values.append(clean_value(src[key]))
|
||||||
|
|
||||||
# Clean and convert values
|
# Clean and convert values
|
||||||
if 'cleanRegex' in m and len(values)>0:
|
if 'cleanRegex' in m and len(values)>0:
|
||||||
new_values=[]
|
new_values=[]
|
||||||
for v in values:
|
for v in values:
|
||||||
nv=re.sub(m['cleanRegex'],'',v)
|
nv=re.sub(m['cleanRegex'],'',v)
|
||||||
if nv!='':
|
if nv!='':
|
||||||
new_values.append(nv)
|
new_values.append(nv)
|
||||||
values=new_values
|
values=new_values
|
||||||
|
|
||||||
if 'convert' in m and len(values)>0:
|
if 'convert' in m and len(values)>0:
|
||||||
new_values=[]
|
new_values=[]
|
||||||
for v in values:
|
for v in values:
|
||||||
nv=m['convert'](v)
|
nv=m['convert'](v)
|
||||||
if nv!='':
|
if nv!='':
|
||||||
new_values.append(nv)
|
new_values.append(nv)
|
||||||
values=new_values
|
values=new_values
|
||||||
|
|
||||||
# Deduplicate values
|
# Deduplicate values
|
||||||
if m.get('deduplicate') and len(values)>1:
|
if m.get('deduplicate') and len(values)>1:
|
||||||
new_values=[]
|
new_values=[]
|
||||||
for v in values:
|
for v in values:
|
||||||
if v not in new_values:
|
if v not in new_values:
|
||||||
new_values.append(v)
|
new_values.append(v)
|
||||||
values=new_values
|
values=new_values
|
||||||
|
|
||||||
# Check values
|
|
||||||
if 'check' in m and len(values)>0:
|
|
||||||
new_values=[]
|
|
||||||
for v in values:
|
|
||||||
if m['check'](v):
|
|
||||||
new_values.append(v)
|
|
||||||
else:
|
|
||||||
logging.debug('Invalid value %s for key %s' % (v,dst_key))
|
|
||||||
if dst_key not in invalid_values:
|
|
||||||
invalid_values[dst_key]=[]
|
|
||||||
if v not in invalid_values[dst_key]:
|
|
||||||
invalid_values[dst_key].append(v)
|
|
||||||
values=new_values
|
|
||||||
|
|
||||||
# Join values
|
# Check values
|
||||||
if 'join' in m and len(values)>1:
|
if 'check' in m and len(values)>0:
|
||||||
values=[m['join'].join(values)]
|
new_values=[]
|
||||||
|
for v in values:
|
||||||
|
if m['check'](v):
|
||||||
|
new_values.append(v)
|
||||||
|
else:
|
||||||
|
logging.debug('Invalid value %s for key %s' % (v,dst_key))
|
||||||
|
if dst_key not in invalid_values:
|
||||||
|
invalid_values[dst_key]=[]
|
||||||
|
if v not in invalid_values[dst_key]:
|
||||||
|
invalid_values[dst_key].append(v)
|
||||||
|
values=new_values
|
||||||
|
|
||||||
# Manage alternative mapping case
|
# Join values
|
||||||
if len(values)==0 and 'or' in m:
|
if 'join' in m and len(values)>1:
|
||||||
values=get_values(dst_key,src,m['or'])
|
values=[m['join'].join(values)]
|
||||||
|
|
||||||
|
# Manage alternative mapping case
|
||||||
|
if len(values)==0 and 'or' in m:
|
||||||
|
values=get_values(dst_key,src,m['or'])
|
||||||
|
|
||||||
|
|
||||||
return values
|
return values
|
||||||
|
|
||||||
for dst_key in sorted(map_keys.keys(), key=lambda x: map_keys[x]['order']):
|
for dst_key in sorted(map_keys.keys(), key=lambda x: map_keys[x]['order']):
|
||||||
values=get_values(dst_key,src,map_keys[dst_key])
|
values=get_values(dst_key,src,map_keys[dst_key])
|
||||||
|
|
||||||
if len(values)==0:
|
if len(values)==0:
|
||||||
if 'required' in map_keys[dst_key] and map_keys[dst_key]['required']:
|
if 'required' in map_keys[dst_key] and map_keys[dst_key]['required']:
|
||||||
logging.debug('Destination key %s could not be filled from source but is required' % dst_key)
|
logging.debug('Destination key %s could not be filled from source but is required' % dst_key)
|
||||||
return False
|
return False
|
||||||
continue
|
continue
|
||||||
|
|
||||||
dst[dst_key]=values
|
dst[dst_key]=values
|
||||||
return dst
|
return dst
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
src={
|
src={
|
||||||
'uid': 'hmartin',
|
'uid': 'hmartin',
|
||||||
'firstname': 'Martin',
|
'firstname': 'Martin',
|
||||||
'lastname': 'Martin',
|
'lastname': 'Martin',
|
||||||
'disp_name': 'Henri Martin',
|
'disp_name': 'Henri Martin',
|
||||||
'line_1': '3 rue de Paris',
|
'line_1': '3 rue de Paris',
|
||||||
'line_2': 'Pour Pierre',
|
'line_2': 'Pour Pierre',
|
||||||
'zip_text': '92 120',
|
'zip_text': '92 120',
|
||||||
'city_text': 'Montrouge',
|
'city_text': 'Montrouge',
|
||||||
'line_city': '92120 Montrouge',
|
'line_city': '92120 Montrouge',
|
||||||
'tel1': '01 00 00 00 00',
|
'tel1': '01 00 00 00 00',
|
||||||
'tel2': '09 00 00 00 00',
|
'tel2': '09 00 00 00 00',
|
||||||
'mobile': '06 00 00 00 00',
|
'mobile': '06 00 00 00 00',
|
||||||
'fax': '01 00 00 00 00',
|
'fax': '01 00 00 00 00',
|
||||||
'email': 'H.MARTIN@GMAIL.COM',
|
'email': 'H.MARTIN@GMAIL.COM',
|
||||||
}
|
}
|
||||||
|
|
||||||
map_c={
|
map_c={
|
||||||
'uid': {'order': 0, 'key': 'uid','required': True},
|
'uid': {'order': 0, 'key': 'uid','required': True},
|
||||||
'givenName': {'order': 1, 'key': 'firstname'},
|
'givenName': {'order': 1, 'key': 'firstname'},
|
||||||
'sn': {'order': 2, 'key': 'lastname'},
|
'sn': {'order': 2, 'key': 'lastname'},
|
||||||
'cn': {'order': 3, 'key': 'disp_name','required': True, 'or': {'attrs': ['firstname','lastname'],'join': ' '}},
|
'cn': {'order': 3, 'key': 'disp_name','required': True, 'or': {'attrs': ['firstname','lastname'],'join': ' '}},
|
||||||
'displayName': {'order': 4, 'other_key': 'displayName'},
|
'displayName': {'order': 4, 'other_key': 'displayName'},
|
||||||
'street': {'order': 5, 'join': ' / ', 'keys': ['ligne_1','ligne_2']},
|
'street': {'order': 5, 'join': ' / ', 'keys': ['ligne_1','ligne_2']},
|
||||||
'postalCode': {'order': 6, 'key': 'zip_text', 'cleanRegex': '[^0-9]'},
|
'postalCode': {'order': 6, 'key': 'zip_text', 'cleanRegex': '[^0-9]'},
|
||||||
'l': {'order': 7, 'key': 'city_text'},
|
'l': {'order': 7, 'key': 'city_text'},
|
||||||
'postalAddress': {'order': 8, 'join': '$', 'keys': ['ligne_1','ligne_2','ligne_city']},
|
'postalAddress': {'order': 8, 'join': '$', 'keys': ['ligne_1','ligne_2','ligne_city']},
|
||||||
'telephoneNumber': {'order': 9, 'keys': ['tel1','tel2'], 'cleanRegex': '[^0-9+]', 'deduplicate': True},
|
'telephoneNumber': {'order': 9, 'keys': ['tel1','tel2'], 'cleanRegex': '[^0-9+]', 'deduplicate': True},
|
||||||
'mobile': {'order': 10,'key': 'mobile'},
|
'mobile': {'order': 10,'key': 'mobile'},
|
||||||
'facsimileTelephoneNumber': {'order': 11,'key': 'fax'},
|
'facsimileTelephoneNumber': {'order': 11,'key': 'fax'},
|
||||||
'mail': {'order': 12,'key': 'email', 'convert': lambda x: x.lower().strip()}
|
'mail': {'order': 12,'key': 'email', 'convert': lambda x: x.lower().strip()}
|
||||||
}
|
}
|
||||||
|
|
||||||
logging.debug('[TEST] Map src=%s / config= %s' % (src,map_c))
|
logging.debug('[TEST] Map src=%s / config= %s' % (src,map_c))
|
||||||
logging.debug('[TEST] Result : %s' % map(map_c,src))
|
logging.debug('[TEST] Result : %s' % map(map_c,src))
|
||||||
|
|
92
MyDB.py
92
MyDB.py
|
@ -6,54 +6,54 @@ import sys
|
||||||
|
|
||||||
class MyDB(object):
|
class MyDB(object):
|
||||||
|
|
||||||
host = ""
|
host = ""
|
||||||
user = ""
|
user = ""
|
||||||
pwd = ""
|
pwd = ""
|
||||||
db = ""
|
db = ""
|
||||||
|
|
||||||
con = 0
|
con = 0
|
||||||
|
|
||||||
def __init__(self,host,user,pwd,db):
|
def __init__(self,host,user,pwd,db):
|
||||||
self.host = host
|
self.host = host
|
||||||
self.user = user
|
self.user = user
|
||||||
self.pwd = pwd
|
self.pwd = pwd
|
||||||
self.db = db
|
self.db = db
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
if self.con == 0:
|
if self.con == 0:
|
||||||
try:
|
try:
|
||||||
con = MySQLdb.connect(self.host,self.user,self.pwd,self.db)
|
con = MySQLdb.connect(self.host,self.user,self.pwd,self.db)
|
||||||
self.con = con
|
self.con = con
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
logging.fatal(e)
|
logging.fatal(e)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def doSQL(self,sql):
|
def doSQL(self,sql):
|
||||||
cursor = self.con.cursor()
|
cursor = self.con.cursor()
|
||||||
try:
|
try:
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
self.con.commit()
|
self.con.commit()
|
||||||
return True
|
return True
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
logging.error('Erreur durant la requete sql %s : %s' % (sql,e))
|
logging.error('Erreur durant la requete sql %s : %s' % (sql,e))
|
||||||
self.con.rollback()
|
self.con.rollback()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def doSelect(self,sql):
|
def doSelect(self,sql):
|
||||||
cursor = self.con.cursor()
|
cursor = self.con.cursor()
|
||||||
try:
|
try:
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
results = cursor.fetchall()
|
results = cursor.fetchall()
|
||||||
return results
|
return results
|
||||||
ret=[]
|
ret=[]
|
||||||
t=0
|
t=0
|
||||||
for row in results:
|
for row in results:
|
||||||
c=0
|
c=0
|
||||||
for field in row:
|
for field in row:
|
||||||
ret[t][c]=field
|
ret[t][c]=field
|
||||||
c=c+1
|
c=c+1
|
||||||
t=t+1
|
t=t+1
|
||||||
return ret
|
return ret
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
logging.error('Erreur durant la requete sql %s : %s' % (sql,e))
|
logging.error('Erreur durant la requete sql %s : %s' % (sql,e))
|
||||||
return False
|
return False
|
||||||
|
|
238
PgDB.py
238
PgDB.py
|
@ -9,21 +9,21 @@ import datetime
|
||||||
|
|
||||||
class PgDB(object):
|
class PgDB(object):
|
||||||
|
|
||||||
host = ""
|
host = ""
|
||||||
user = ""
|
user = ""
|
||||||
pwd = ""
|
pwd = ""
|
||||||
db = ""
|
db = ""
|
||||||
|
|
||||||
con = 0
|
con = 0
|
||||||
|
|
||||||
date_format = '%Y-%m-%d'
|
date_format = '%Y-%m-%d'
|
||||||
datetime_format = '%Y-%m-%d %H:%M:%S'
|
datetime_format = '%Y-%m-%d %H:%M:%S'
|
||||||
|
|
||||||
def __init__(self,host,user,pwd,db):
|
def __init__(self,host,user,pwd,db):
|
||||||
self.host = host
|
self.host = host
|
||||||
self.user = user
|
self.user = user
|
||||||
self.pwd = pwd
|
self.pwd = pwd
|
||||||
self.db = db
|
self.db = db
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
if self.con == 0:
|
if self.con == 0:
|
||||||
|
@ -43,32 +43,32 @@ class PgDB(object):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
if self.con:
|
if self.con:
|
||||||
self.con.close()
|
self.con.close()
|
||||||
|
|
||||||
def setEncoding(self,enc):
|
def setEncoding(self,enc):
|
||||||
if self.con:
|
if self.con:
|
||||||
try:
|
try:
|
||||||
self.con.set_client_encoding(enc)
|
self.con.set_client_encoding(enc)
|
||||||
return True
|
return True
|
||||||
except Exception:
|
except Exception:
|
||||||
logging.error('An error occured setting Postgresql database connection encoding to "%s"', enc, exc_info=1)
|
logging.error('An error occured setting Postgresql database connection encoding to "%s"', enc, exc_info=1)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def doSQL(self,sql,params=None):
|
def doSQL(self,sql,params=None):
|
||||||
cursor = self.con.cursor()
|
cursor = self.con.cursor()
|
||||||
try:
|
try:
|
||||||
if params is None:
|
if params is None:
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
else:
|
else:
|
||||||
cursor.execute(sql,params)
|
cursor.execute(sql,params)
|
||||||
self.con.commit()
|
self.con.commit()
|
||||||
return True
|
return True
|
||||||
except Exception:
|
except Exception:
|
||||||
logging.error(u'Error during SQL request "%s"', sql.decode('utf-8', 'ignore'), exc_info=1)
|
logging.error(u'Error during SQL request "%s"', sql.decode('utf-8', 'ignore'), exc_info=1)
|
||||||
self.con.rollback()
|
self.con.rollback()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def doSelect(self,sql,params):
|
def doSelect(self,sql,params):
|
||||||
cursor = self.con.cursor()
|
cursor = self.con.cursor()
|
||||||
|
@ -83,109 +83,109 @@ class PgDB(object):
|
||||||
logging.error(u'Error during SQL request "%s"', sql.decode('utf-8', 'ignore'), exc_info=1)
|
logging.error(u'Error during SQL request "%s"', sql.decode('utf-8', 'ignore'), exc_info=1)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
#
|
#
|
||||||
# SQL helpers
|
# SQL helpers
|
||||||
#
|
#
|
||||||
def _quote_value(self, value):
|
def _quote_value(self, value):
|
||||||
if isinstance(value, int) or isinstance(value, float):
|
if isinstance(value, int) or isinstance(value, float):
|
||||||
return unicode(value)
|
return unicode(value)
|
||||||
|
|
||||||
if isinstance(value, str):
|
if isinstance(value, str):
|
||||||
value = unicode(value)
|
value = unicode(value)
|
||||||
elif isinstance(value, datetime.datetime):
|
elif isinstance(value, datetime.datetime):
|
||||||
value = unicode(self._format_datetime(value))
|
value = unicode(self._format_datetime(value))
|
||||||
elif isinstance(value, datetime.date):
|
elif isinstance(value, datetime.date):
|
||||||
value = unicode(self._format_date(value))
|
value = unicode(self._format_date(value))
|
||||||
|
|
||||||
return u"'%s'" % value.replace(u"'",u"''")
|
return u"'%s'" % value.replace(u"'",u"''")
|
||||||
|
|
||||||
def _format_where_clauses(self, where_clauses, where_op=u'AND'):
|
def _format_where_clauses(self, where_clauses, where_op=u'AND'):
|
||||||
if isinstance(where_clauses, str):
|
if isinstance(where_clauses, str):
|
||||||
return where_clauses
|
return where_clauses
|
||||||
elif isinstance(where_clauses, list):
|
elif isinstance(where_clauses, list):
|
||||||
return (u" %s " % where_op).join(where_clauses)
|
return (u" %s " % where_op).join(where_clauses)
|
||||||
elif isinstance(where_clauses, dict):
|
elif isinstance(where_clauses, dict):
|
||||||
return (u" %s " % where_op).join(map(lambda x: "%s=%s" % (x, self._quote_value(where_clauses[x])), where_clauses))
|
return (u" %s " % where_op).join(map(lambda x: "%s=%s" % (x, self._quote_value(where_clauses[x])), where_clauses))
|
||||||
logging.error('Unsupported where clauses type %s', type(where_clauses))
|
logging.error('Unsupported where clauses type %s', type(where_clauses))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _format_datetime(self, datetime):
|
def _format_datetime(self, datetime):
|
||||||
return datetime.strftime(self.datetime_format)
|
return datetime.strftime(self.datetime_format)
|
||||||
|
|
||||||
def _format_date(self, date):
|
def _format_date(self, date):
|
||||||
return date.strftime(self.date_format)
|
return date.strftime(self.date_format)
|
||||||
|
|
||||||
def time2datetime(self, time):
|
def time2datetime(self, time):
|
||||||
return self._format_datetime(datetime.fromtimestamp(int(time)))
|
return self._format_datetime(datetime.fromtimestamp(int(time)))
|
||||||
|
|
||||||
def time2date(self, time):
|
def time2date(self, time):
|
||||||
return self._format_date(datetime.fromtimestamp(int(time)))
|
return self._format_date(datetime.fromtimestamp(int(time)))
|
||||||
|
|
||||||
def insert(self, table, values, just_try=False):
|
def insert(self, table, values, just_try=False):
|
||||||
sql=u"INSERT INTO %s (%s) VALUES (%s)" % (table, u', '.join(values.keys()), u", ".join(map(lambda x: self._quote_value(values[x]), values)))
|
sql=u"INSERT INTO %s (%s) VALUES (%s)" % (table, u', '.join(values.keys()), u", ".join(map(lambda x: self._quote_value(values[x]), values)))
|
||||||
|
|
||||||
if just_try:
|
if just_try:
|
||||||
logging.debug(u"Just-try mode : execute INSERT query : %s", sql)
|
logging.debug(u"Just-try mode : execute INSERT query : %s", sql)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
logging.debug(sql)
|
logging.debug(sql)
|
||||||
if not self.doSQL(sql):
|
if not self.doSQL(sql):
|
||||||
logging.error(u"Fail to execute INSERT query (SQL : %s)" % sql)
|
logging.error(u"Fail to execute INSERT query (SQL : %s)" % sql)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def update(self, table, values, where_clauses, where_op=u'AND', just_try=False):
|
def update(self, table, values, where_clauses, where_op=u'AND', just_try=False):
|
||||||
where=self._format_where_clauses(where_clauses, where_op=where_op)
|
where=self._format_where_clauses(where_clauses, where_op=where_op)
|
||||||
if not where:
|
if not where:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
sql=u"UPDATE %s SET %s WHERE %s" % (table, u", ".join(map(lambda x: "%s=%s" % (x, self._quote_value(values[x])), values)), where)
|
sql=u"UPDATE %s SET %s WHERE %s" % (table, u", ".join(map(lambda x: "%s=%s" % (x, self._quote_value(values[x])), values)), where)
|
||||||
|
|
||||||
if just_try:
|
if just_try:
|
||||||
logging.debug(u"Just-try mode : execute UPDATE query : %s", sql)
|
logging.debug(u"Just-try mode : execute UPDATE query : %s", sql)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
logging.debug(sql)
|
logging.debug(sql)
|
||||||
if not self.doSQL(sql):
|
if not self.doSQL(sql):
|
||||||
logging.error(u"Fail to execute UPDATE query (SQL : %s)", sql)
|
logging.error(u"Fail to execute UPDATE query (SQL : %s)", sql)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def delete(self, table, where_clauses, where_op=u'AND', just_try=False):
|
def delete(self, table, where_clauses, where_op=u'AND', just_try=False):
|
||||||
where=self._format_where_clauses(where_clauses, where_op=where_op)
|
where=self._format_where_clauses(where_clauses, where_op=where_op)
|
||||||
if not where:
|
if not where:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
sql=u"DELETE FROM %s WHERE %s" % (table, where)
|
sql=u"DELETE FROM %s WHERE %s" % (table, where)
|
||||||
|
|
||||||
if just_try:
|
if just_try:
|
||||||
logging.debug(u"Just-try mode : execute DELETE query : %s", sql)
|
logging.debug(u"Just-try mode : execute DELETE query : %s", sql)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
logging.debug(sql)
|
logging.debug(sql)
|
||||||
if not self.doSQL(sql):
|
if not self.doSQL(sql):
|
||||||
logging.error(u"Fail to execute DELETE query (SQL : %s)", sql)
|
logging.error(u"Fail to execute DELETE query (SQL : %s)", sql)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def select(self, table, where_clauses=None, fields=None, where_op=u'AND', order_by=None, just_try=False):
|
def select(self, table, where_clauses=None, fields=None, where_op=u'AND', order_by=None, just_try=False):
|
||||||
sql = u"SELECT "
|
sql = u"SELECT "
|
||||||
if fields is None:
|
if fields is None:
|
||||||
sql += "*"
|
sql += "*"
|
||||||
elif isinstance(fields, str) or isinstance(fields, unicode):
|
elif isinstance(fields, str) or isinstance(fields, unicode):
|
||||||
sql += fields
|
sql += fields
|
||||||
else:
|
else:
|
||||||
sql += u", ".join(fields)
|
sql += u", ".join(fields)
|
||||||
|
|
||||||
sql += u" FROM " + table
|
sql += u" FROM " + table
|
||||||
if where_clauses:
|
if where_clauses:
|
||||||
where=self._format_where_clauses(where_clauses, where_op=where_op)
|
where=self._format_where_clauses(where_clauses, where_op=where_op)
|
||||||
if not where:
|
if not where:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
sql += u" WHERE " + where
|
sql += u" WHERE " + where
|
||||||
|
|
||||||
if order_by:
|
if order_by:
|
||||||
sql += u"ORDER %s" % order_by
|
sql += u"ORDER %s" % order_by
|
||||||
|
|
||||||
return self.doSelect(sql)
|
return self.doSelect(sql)
|
||||||
|
|
378
opening_hours.py
378
opening_hours.py
|
@ -2,206 +2,206 @@ import datetime, re, time, logging
|
||||||
|
|
||||||
week_days=['lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi', 'dimanche']
|
week_days=['lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi', 'dimanche']
|
||||||
def easter_date(year):
|
def easter_date(year):
|
||||||
a=year//100
|
a=year//100
|
||||||
b=year%100
|
b=year%100
|
||||||
c=(3*(a+25))//4
|
c=(3*(a+25))//4
|
||||||
d=(3*(a+25))%4
|
d=(3*(a+25))%4
|
||||||
e=(8*(a+11))//25
|
e=(8*(a+11))//25
|
||||||
f=(5*a+b)%19
|
f=(5*a+b)%19
|
||||||
g=(19*f+c-e)%30
|
g=(19*f+c-e)%30
|
||||||
h=(f+11*g)//319
|
h=(f+11*g)//319
|
||||||
j=(60*(5-d)+b)//4
|
j=(60*(5-d)+b)//4
|
||||||
k=(60*(5-d)+b)%4
|
k=(60*(5-d)+b)%4
|
||||||
m=(2*j-k-g+h)%7
|
m=(2*j-k-g+h)%7
|
||||||
n=(g-h+m+114)//31
|
n=(g-h+m+114)//31
|
||||||
p=(g-h+m+114)%31
|
p=(g-h+m+114)%31
|
||||||
day=p+1
|
day=p+1
|
||||||
month=n
|
month=n
|
||||||
return datetime.date(year, month, day)
|
return datetime.date(year, month, day)
|
||||||
|
|
||||||
def nonworking_french_public_days_of_the_year(year=None):
|
def nonworking_french_public_days_of_the_year(year=None):
|
||||||
if year is None:
|
if year is None:
|
||||||
year=datetime.date.today().year
|
year=datetime.date.today().year
|
||||||
dp=easter_date(year)
|
dp=easter_date(year)
|
||||||
return {
|
return {
|
||||||
'1janvier': datetime.date(year, 1, 1),
|
'1janvier': datetime.date(year, 1, 1),
|
||||||
'paques': dp,
|
'paques': dp,
|
||||||
'lundi_paques': (dp+datetime.timedelta(1)),
|
'lundi_paques': (dp+datetime.timedelta(1)),
|
||||||
'1mai': datetime.date(year, 5, 1),
|
'1mai': datetime.date(year, 5, 1),
|
||||||
'8mai': datetime.date(year, 5, 8),
|
'8mai': datetime.date(year, 5, 8),
|
||||||
'jeudi_ascension': (dp+datetime.timedelta(39)),
|
'jeudi_ascension': (dp+datetime.timedelta(39)),
|
||||||
'pentecote': (dp+datetime.timedelta(49)),
|
'pentecote': (dp+datetime.timedelta(49)),
|
||||||
'lundi_pentecote': (dp+datetime.timedelta(50)),
|
'lundi_pentecote': (dp+datetime.timedelta(50)),
|
||||||
'14juillet': datetime.date(year, 7, 14),
|
'14juillet': datetime.date(year, 7, 14),
|
||||||
'15aout': datetime.date(year, 8, 15),
|
'15aout': datetime.date(year, 8, 15),
|
||||||
'1novembre': datetime.date(year, 11, 1),
|
'1novembre': datetime.date(year, 11, 1),
|
||||||
'11novembre': datetime.date(year, 11, 11),
|
'11novembre': datetime.date(year, 11, 11),
|
||||||
'noel': datetime.date(year, 12, 25),
|
'noel': datetime.date(year, 12, 25),
|
||||||
'saint_etienne': datetime.date(year, 12, 26),
|
'saint_etienne': datetime.date(year, 12, 26),
|
||||||
}
|
}
|
||||||
|
|
||||||
def parse_exceptional_closures(values):
|
def parse_exceptional_closures(values):
|
||||||
exceptional_closures=[]
|
exceptional_closures=[]
|
||||||
date_pattern=re.compile('^([0-9]{2})/([0-9]{2})/([0-9]{4})$')
|
date_pattern=re.compile('^([0-9]{2})/([0-9]{2})/([0-9]{4})$')
|
||||||
time_pattern=re.compile('^([0-9]{1,2})h([0-9]{2})?$')
|
time_pattern=re.compile('^([0-9]{1,2})h([0-9]{2})?$')
|
||||||
for value in values:
|
for value in values:
|
||||||
days=[]
|
days=[]
|
||||||
hours_periods=[]
|
hours_periods=[]
|
||||||
words=value.strip().split()
|
words=value.strip().split()
|
||||||
for word in words:
|
for word in words:
|
||||||
if word=='':
|
if word=='':
|
||||||
continue
|
continue
|
||||||
parts=word.split('-')
|
parts=word.split('-')
|
||||||
if len(parts)==1:
|
if len(parts)==1:
|
||||||
# ex : 31/02/2017
|
# ex : 31/02/2017
|
||||||
ptime=time.strptime(word,'%d/%m/%Y')
|
ptime=time.strptime(word,'%d/%m/%Y')
|
||||||
date=datetime.date(ptime.tm_year, ptime.tm_mon, ptime.tm_mday)
|
date=datetime.date(ptime.tm_year, ptime.tm_mon, ptime.tm_mday)
|
||||||
if date not in days:
|
if date not in days:
|
||||||
days.append(date)
|
days.append(date)
|
||||||
elif len(parts)==2:
|
elif len(parts)==2:
|
||||||
# ex : 18/12/2017-20/12/2017 ou 9h-10h30
|
# ex : 18/12/2017-20/12/2017 ou 9h-10h30
|
||||||
if date_pattern.match(parts[0]) and date_pattern.match(parts[1]):
|
if date_pattern.match(parts[0]) and date_pattern.match(parts[1]):
|
||||||
# ex : 18/12/2017-20/12/2017
|
# ex : 18/12/2017-20/12/2017
|
||||||
pstart=time.strptime(parts[0],'%d/%m/%Y')
|
pstart=time.strptime(parts[0],'%d/%m/%Y')
|
||||||
pstop=time.strptime(parts[1],'%d/%m/%Y')
|
pstop=time.strptime(parts[1],'%d/%m/%Y')
|
||||||
if pstop<=pstart:
|
if pstop<=pstart:
|
||||||
raise ValueError('Day %s <= %s' % (parts[1],parts[0]))
|
raise ValueError('Day %s <= %s' % (parts[1],parts[0]))
|
||||||
|
|
||||||
date=datetime.date(pstart.tm_year, pstart.tm_mon, pstart.tm_mday)
|
date=datetime.date(pstart.tm_year, pstart.tm_mon, pstart.tm_mday)
|
||||||
stop_date=datetime.date(pstop.tm_year, pstart.tm_mon, pstart.tm_mday)
|
stop_date=datetime.date(pstop.tm_year, pstart.tm_mon, pstart.tm_mday)
|
||||||
while date<=stop_date:
|
while date<=stop_date:
|
||||||
if date not in days:
|
if date not in days:
|
||||||
days.append(date)
|
days.append(date)
|
||||||
date+=datetime.timedelta(days=1)
|
date+=datetime.timedelta(days=1)
|
||||||
else:
|
else:
|
||||||
# ex : 9h-10h30
|
# ex : 9h-10h30
|
||||||
mstart=time_pattern.match(parts[0])
|
mstart=time_pattern.match(parts[0])
|
||||||
mstop=time_pattern.match(parts[1])
|
mstop=time_pattern.match(parts[1])
|
||||||
if not mstart or not mstop:
|
if not mstart or not mstop:
|
||||||
raise ValueError('"%s" is not a valid time period' % word)
|
raise ValueError('"%s" is not a valid time period' % word)
|
||||||
hstart=datetime.time(int(mstart.group(1)), int(mstart.group(2) or 0))
|
hstart=datetime.time(int(mstart.group(1)), int(mstart.group(2) or 0))
|
||||||
hstop=datetime.time(int(mstop.group(1)), int(mstop.group(2) or 0))
|
hstop=datetime.time(int(mstop.group(1)), int(mstop.group(2) or 0))
|
||||||
if hstop<=hstart:
|
if hstop<=hstart:
|
||||||
raise ValueError('Time %s <= %s' % (parts[1],parts[0]))
|
raise ValueError('Time %s <= %s' % (parts[1],parts[0]))
|
||||||
hours_periods.append({'start': hstart, 'stop': hstop})
|
hours_periods.append({'start': hstart, 'stop': hstop})
|
||||||
else:
|
else:
|
||||||
raise ValueError('Invalid number of part in this word : "%s"' % word)
|
raise ValueError('Invalid number of part in this word : "%s"' % word)
|
||||||
if not days:
|
if not days:
|
||||||
raise ValueError('No days found in value "%s"' % word)
|
raise ValueError('No days found in value "%s"' % word)
|
||||||
exceptional_closures.append({'days': days, 'hours_periods': hours_periods})
|
exceptional_closures.append({'days': days, 'hours_periods': hours_periods})
|
||||||
return exceptional_closures
|
return exceptional_closures
|
||||||
|
|
||||||
|
|
||||||
def parse_normal_opening_hours(values):
|
def parse_normal_opening_hours(values):
|
||||||
normal_opening_hours=[]
|
normal_opening_hours=[]
|
||||||
time_pattern=re.compile('^([0-9]{1,2})h([0-9]{2})?$')
|
time_pattern=re.compile('^([0-9]{1,2})h([0-9]{2})?$')
|
||||||
for value in values:
|
for value in values:
|
||||||
days=[]
|
days=[]
|
||||||
hours_periods=[]
|
hours_periods=[]
|
||||||
words=value.strip().split()
|
words=value.strip().split()
|
||||||
for word in words:
|
for word in words:
|
||||||
if word=='':
|
if word=='':
|
||||||
continue
|
continue
|
||||||
parts=word.split('-')
|
parts=word.split('-')
|
||||||
if len(parts)==1:
|
if len(parts)==1:
|
||||||
# ex : jeudi
|
# ex : jeudi
|
||||||
if word not in week_days:
|
if word not in week_days:
|
||||||
raise ValueError('"%s" is not a valid week day' % word)
|
raise ValueError('"%s" is not a valid week day' % word)
|
||||||
if word not in days:
|
if word not in days:
|
||||||
days.append(word)
|
days.append(word)
|
||||||
elif len(parts)==2:
|
elif len(parts)==2:
|
||||||
# ex : lundi-jeudi ou 9h-10h30
|
# ex : lundi-jeudi ou 9h-10h30
|
||||||
if parts[0] in week_days and parts[1] in week_days:
|
if parts[0] in week_days and parts[1] in week_days:
|
||||||
# ex : lundi-jeudi
|
# ex : lundi-jeudi
|
||||||
if week_days.index(parts[1]) <= week_days.index(parts[0]):
|
if week_days.index(parts[1]) <= week_days.index(parts[0]):
|
||||||
raise ValueError('"%s" is before "%s"' % (parts[1],parts[0]))
|
raise ValueError('"%s" is before "%s"' % (parts[1],parts[0]))
|
||||||
started=False
|
started=False
|
||||||
for d in week_days:
|
for d in week_days:
|
||||||
if not started and d!=parts[0]:
|
if not started and d!=parts[0]:
|
||||||
continue
|
continue
|
||||||
started=True
|
started=True
|
||||||
if d not in days:
|
if d not in days:
|
||||||
days.append(d)
|
days.append(d)
|
||||||
if d==parts[1]:
|
if d==parts[1]:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
#ex : 9h-10h30
|
#ex : 9h-10h30
|
||||||
mstart=time_pattern.match(parts[0])
|
mstart=time_pattern.match(parts[0])
|
||||||
mstop=time_pattern.match(parts[1])
|
mstop=time_pattern.match(parts[1])
|
||||||
if not mstart or not mstop:
|
if not mstart or not mstop:
|
||||||
raise ValueError('"%s" is not a valid time period' % word)
|
raise ValueError('"%s" is not a valid time period' % word)
|
||||||
hstart=datetime.time(int(mstart.group(1)), int(mstart.group(2) or 0))
|
hstart=datetime.time(int(mstart.group(1)), int(mstart.group(2) or 0))
|
||||||
hstop=datetime.time(int(mstop.group(1)), int(mstop.group(2) or 0))
|
hstop=datetime.time(int(mstop.group(1)), int(mstop.group(2) or 0))
|
||||||
if hstop<=hstart:
|
if hstop<=hstart:
|
||||||
raise ValueError('Time %s <= %s' % (parts[1],parts[0]))
|
raise ValueError('Time %s <= %s' % (parts[1],parts[0]))
|
||||||
hours_periods.append({'start': hstart, 'stop': hstop})
|
hours_periods.append({'start': hstart, 'stop': hstop})
|
||||||
else:
|
else:
|
||||||
raise ValueError('Invalid number of part in this word : "%s"' % word)
|
raise ValueError('Invalid number of part in this word : "%s"' % word)
|
||||||
if not days and not hours_periods:
|
if not days and not hours_periods:
|
||||||
raise ValueError('No days or hours period found in this value : "%s"' % value)
|
raise ValueError('No days or hours period found in this value : "%s"' % value)
|
||||||
normal_opening_hours.append({'days': days, 'hours_periods': hours_periods})
|
normal_opening_hours.append({'days': days, 'hours_periods': hours_periods})
|
||||||
return normal_opening_hours
|
return normal_opening_hours
|
||||||
|
|
||||||
def is_closed(normal_opening_hours_values=[],exceptional_closures_values=[],nonworking_public_holidays_values=[], when=datetime.datetime.now(), on_error='raise', exceptional_closure_on_nonworking_public_days=False):
|
def is_closed(normal_opening_hours_values=[],exceptional_closures_values=[],nonworking_public_holidays_values=[], when=datetime.datetime.now(), on_error='raise', exceptional_closure_on_nonworking_public_days=False):
|
||||||
when_date=when.date()
|
when_date=when.date()
|
||||||
when_time=when.time()
|
when_time=when.time()
|
||||||
when_weekday=week_days[when.timetuple().tm_wday]
|
when_weekday=week_days[when.timetuple().tm_wday]
|
||||||
on_error_result=None
|
on_error_result=None
|
||||||
if on_error=='closed':
|
if on_error=='closed':
|
||||||
on_error_result={'closed': True, 'exceptional_closure': False, 'exceptional_closure_all_day': False}
|
on_error_result={'closed': True, 'exceptional_closure': False, 'exceptional_closure_all_day': False}
|
||||||
elif on_error=='opened':
|
elif on_error=='opened':
|
||||||
on_error_result={'closed': False, 'exceptional_closure': False, 'exceptional_closure_all_day': False}
|
on_error_result={'closed': False, 'exceptional_closure': False, 'exceptional_closure_all_day': False}
|
||||||
|
|
||||||
logging.debug("%s => %s / %s / %s" % (when, when_date, when_time, when_weekday))
|
logging.debug("%s => %s / %s / %s" % (when, when_date, when_time, when_weekday))
|
||||||
if len(nonworking_public_holidays_values)>0:
|
if len(nonworking_public_holidays_values)>0:
|
||||||
logging.debug("Nonworking public holidays : %s" % nonworking_public_holidays_values)
|
logging.debug("Nonworking public holidays : %s" % nonworking_public_holidays_values)
|
||||||
nonworking_days=nonworking_french_public_days_of_the_year()
|
nonworking_days=nonworking_french_public_days_of_the_year()
|
||||||
for day in nonworking_public_holidays_values:
|
for day in nonworking_public_holidays_values:
|
||||||
if day in nonworking_days and when_date==nonworking_days[day]:
|
if day in nonworking_days and when_date==nonworking_days[day]:
|
||||||
logging.debug("Non working day : %s" % day)
|
logging.debug("Non working day : %s" % day)
|
||||||
return {'closed': True, 'exceptional_closure': exceptional_closure_on_nonworking_public_days, 'exceptional_closure_all_day': exceptional_closure_on_nonworking_public_days}
|
return {'closed': True, 'exceptional_closure': exceptional_closure_on_nonworking_public_days, 'exceptional_closure_all_day': exceptional_closure_on_nonworking_public_days}
|
||||||
|
|
||||||
if len(exceptional_closures_values)>0:
|
if len(exceptional_closures_values)>0:
|
||||||
try:
|
try:
|
||||||
exceptional_closures=parse_exceptional_closures(exceptional_closures_values)
|
exceptional_closures=parse_exceptional_closures(exceptional_closures_values)
|
||||||
logging.debug('Exceptional closures : %s' % exceptional_closures)
|
logging.debug('Exceptional closures : %s' % exceptional_closures)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
logging.error("%s => Not closed by default" % e)
|
logging.error("%s => Not closed by default" % e)
|
||||||
if on_error_result is None:
|
if on_error_result is None:
|
||||||
raise e
|
raise e
|
||||||
return on_error_result
|
return on_error_result
|
||||||
for cl in exceptional_closures:
|
for cl in exceptional_closures:
|
||||||
if when_date not in cl['days']:
|
if when_date not in cl['days']:
|
||||||
logging.debug("when_date (%s) no in days (%s)" % (when_date,cl['days']))
|
logging.debug("when_date (%s) no in days (%s)" % (when_date,cl['days']))
|
||||||
continue
|
continue
|
||||||
if not cl['hours_periods']:
|
if not cl['hours_periods']:
|
||||||
# All day exceptional closure
|
# All day exceptional closure
|
||||||
return {'closed': True, 'exceptional_closure': True, 'exceptional_closure_all_day': True}
|
return {'closed': True, 'exceptional_closure': True, 'exceptional_closure_all_day': True}
|
||||||
for hp in cl['hours_periods']:
|
for hp in cl['hours_periods']:
|
||||||
if hp['start']<=when_time and hp['stop']>= when_time:
|
if hp['start']<=when_time and hp['stop']>= when_time:
|
||||||
return {'closed': True, 'exceptional_closure': True, 'exceptional_closure_all_day': False}
|
return {'closed': True, 'exceptional_closure': True, 'exceptional_closure_all_day': False}
|
||||||
|
|
||||||
if len(normal_opening_hours_values)>0:
|
if len(normal_opening_hours_values)>0:
|
||||||
try:
|
try:
|
||||||
normal_opening_hours=parse_normal_opening_hours(normal_opening_hours_values)
|
normal_opening_hours=parse_normal_opening_hours(normal_opening_hours_values)
|
||||||
logging.debug('Normal opening hours : %s' % normal_opening_hours)
|
logging.debug('Normal opening hours : %s' % normal_opening_hours)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
logging.error("%s => Not closed by default" % e)
|
logging.error("%s => Not closed by default" % e)
|
||||||
if on_error_result is None:
|
if on_error_result is None:
|
||||||
raise e
|
raise e
|
||||||
return on_error_result
|
return on_error_result
|
||||||
for oh in normal_opening_hours:
|
for oh in normal_opening_hours:
|
||||||
if oh['days'] and when_weekday not in oh['days']:
|
if oh['days'] and when_weekday not in oh['days']:
|
||||||
logging.debug("when_weekday (%s) no in days (%s)" % (when_weekday,oh['days']))
|
logging.debug("when_weekday (%s) no in days (%s)" % (when_weekday,oh['days']))
|
||||||
continue
|
continue
|
||||||
if not oh['hours_periods']:
|
if not oh['hours_periods']:
|
||||||
# All day opened
|
# All day opened
|
||||||
return {'closed': False, 'exceptional_closure': False, 'exceptional_closure_all_day': False}
|
return {'closed': False, 'exceptional_closure': False, 'exceptional_closure_all_day': False}
|
||||||
for hp in oh['hours_periods']:
|
for hp in oh['hours_periods']:
|
||||||
if hp['start']<=when_time and hp['stop']>= when_time:
|
if hp['start']<=when_time and hp['stop']>= when_time:
|
||||||
return {'closed': False, 'exceptional_closure': False, 'exceptional_closure_all_day': False}
|
return {'closed': False, 'exceptional_closure': False, 'exceptional_closure_all_day': False}
|
||||||
logging.debug("Not in normal opening hours => closed")
|
logging.debug("Not in normal opening hours => closed")
|
||||||
return {'closed': True, 'exceptional_closure': False, 'exceptional_closure_all_day': False}
|
return {'closed': True, 'exceptional_closure': False, 'exceptional_closure_all_day': False}
|
||||||
|
|
||||||
# Not a nonworking day, not during exceptional closure and no normal opening hours defined => Opened
|
# Not a nonworking day, not during exceptional closure and no normal opening hours defined => Opened
|
||||||
return {'closed': False, 'exceptional_closure': False, 'exceptional_closure_all_day': False}
|
return {'closed': False, 'exceptional_closure': False, 'exceptional_closure_all_day': False}
|
||||||
|
|
Loading…
Reference in a new issue