You've already forked my-video-workflow
初次提交
This commit is contained in:
25
entity/File.py
Normal file
25
entity/File.py
Normal 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)
|
Reference in New Issue
Block a user