def getEtag(fn): "利用文件名和上次修改时间生成Etag" if not exists(fn): return None try: mtime = getmtime(fn) except: mtime = time() return md5(f"{fn}{mtime}")
def getlanEtag(sn: str, lan: str, sn2: str = "bili"): "语言资源文件生成Etag" if lan == "en": fn = f"Language/{sn2}.{sn}.pot" else: fn = f"Language/{sn2}.{sn}.{lan}.po" if not exists(fn): fn = f'Language/{sn2}.{sn}.pot' if not exists(fn): return None try: mtime = getmtime(fn) except: mtime = time() return md5(f"{fn}{mtime}")
import sys from os.path import abspath if abspath('tests/') not in sys.path: sys.path.append(abspath('tests/')) from utils import DebugList, debug from hashl import sha512, sha256, md5 dl = DebugList('hashl.txt') debug(sha512('test'), dl=dl) debug(sha256('test'), dl=dl) debug(md5('test'), dl=dl)