TypeHint
This commit is contained in:
parent
c3f461aa20
commit
4e81c96dee
@ -1,6 +1,7 @@
|
||||
import datetime
|
||||
import os
|
||||
import argparse
|
||||
from typing import Union
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
@ -18,7 +19,7 @@ def check_file_exist(file):
|
||||
raise FileNotFoundError("文件不存在:%s" % file)
|
||||
|
||||
|
||||
def get_file_start(file: os.PathLike[str]) -> float:
|
||||
def get_file_start(file: Union[os.PathLike[str], str]) -> float:
|
||||
with open(file, "r", encoding="utf-8") as f:
|
||||
soup = BeautifulSoup("".join(f.readlines()), "lxml")
|
||||
danmaku_item = soup.find("d")
|
||||
@ -34,7 +35,7 @@ def get_file_start(file: os.PathLike[str]) -> float:
|
||||
return bias_ts_ms / 1000 - bias_sec
|
||||
|
||||
|
||||
def diff_danmaku_files(base_file: os.PathLike[str], file: os.PathLike[str]) -> float:
|
||||
def diff_danmaku_files(base_file: Union[os.PathLike[str], str], file: Union[os.PathLike[str], str]) -> float:
|
||||
return get_file_start(file) - get_file_start(base_file)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user