Page MenuHomec4science

copyright_db.py
No OneTemporary

File Metadata

Created
Wed, May 1, 14:53

copyright_db.py

""" copyright_db.py: Description of the copyrights"""
__author__ = "Guillaume Anciaux and Nicolas Richart"
__credits__ = [
"Guillaume Anciaux <guillaume.anciaux@epfl.ch>",
"Nicolas Richart <nicolas.richart@epfl.ch>",
]
__copyright__ = "Copyright (©) 2010-2021 EPFL (Ecole Polytechnique Fédérale" \
" de Lausanne) Laboratory (LSMS - Laboratoire de Simulation" \
" en Mécanique des Solides)"
__license__ = "GPLv3"
__version__ = "2.0"
from . import export
from datetime import datetime as dt
@export
class CopyrightDB:
def __init__(self, db):
self.__db = db
self._copyrights = self.__db.copyrights
def find_by_id(self, lid):
find = [copy for copy in self._copyrights
if copy.lid == lid]
if find:
return find[0]
else:
return None
def find_by_date(self, date):
if type(date) == str:
date = dt.strptime(date, "%d-%m-%Y")
elif type(date) == float:
date = dt.fromtimestamp(date)
find = [copy for copy in self._copyrights
if copy.start < date <= copy.end]
if find:
return find[0]
else:
return None

Event Timeline