初次提交

This commit is contained in:
2022-04-15 12:26:43 +08:00
commit 09b2956573
30 changed files with 952 additions and 0 deletions

25
entity/File.py Normal file
View File

@ -0,0 +1,25 @@
import os
from os import PathLike
from typing import Union, Optional
class File(object):
base_path: Optional[Union[os.PathLike[str], str]]
file: Union[PathLike[str], str]
def __init__(self, file: Union[os.PathLike[str], str], base_path: Optional[Union[os.PathLike[str], str]] = None):
self.file = file
self.base_path = base_path
@property
def full_path(self) -> str:
if self.base_path is None or len(self.base_path.strip()) == 0:
return self.file
else:
return os.path.join(self.base_path, self.file)
def abs_path(self) -> str:
return os.path.abspath(self.full_path)
def exist(self) -> bool:
return os.path.exists(self.full_path)