mirror of
https://github.com/master-of-zen/Av1an.git
synced 2024-11-25 02:29:40 +00:00
add output overwrite promt
This commit is contained in:
parent
6b06327103
commit
7c1e3dc8d8
2 changed files with 22 additions and 4 deletions
|
@ -38,6 +38,7 @@ class Main:
|
||||||
project = Project(vars(self.args))
|
project = Project(vars(self.args))
|
||||||
project.input = file
|
project.input = file
|
||||||
project.outputs_filenames()
|
project.outputs_filenames()
|
||||||
|
project.promt_output_overwrite()
|
||||||
queue.append(project)
|
queue.append(project)
|
||||||
return queue
|
return queue
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ class Project(object):
|
||||||
|
|
||||||
def outputs_filenames(self):
|
def outputs_filenames(self):
|
||||||
"""
|
"""
|
||||||
Set output filename
|
Set output filename and promts overwrite if file exists
|
||||||
|
|
||||||
:param project: the Project
|
:param project: the Project
|
||||||
"""
|
"""
|
||||||
|
@ -137,15 +137,32 @@ class Project(object):
|
||||||
|
|
||||||
# Check for non-empty string
|
# Check for non-empty string
|
||||||
if isinstance(self.output_file, str) and self.output_file:
|
if isinstance(self.output_file, str) and self.output_file:
|
||||||
if self.output_file[-1] in ('\\', '/'):
|
if self.output_file[-1] in ("\\", "/"):
|
||||||
if not Path(self.output_file).exists():
|
if not Path(self.output_file).exists():
|
||||||
os.makedirs(Path(self.output_file), exist_ok=True)
|
os.makedirs(Path(self.output_file), exist_ok=True)
|
||||||
self.output_file = Path(f"{self.output_file}{self.input.stem}_{self.encoder}{suffix}")
|
self.output_file = Path(
|
||||||
|
f"{self.output_file}{self.input.stem}_{self.encoder}{suffix}"
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
self.output_file = Path(self.output_file).with_suffix(suffix)
|
self.output_file = Path(self.output_file).with_suffix(suffix)
|
||||||
else:
|
else:
|
||||||
self.output_file = Path(f"{self.input.stem}_{self.encoder}{suffix}")
|
self.output_file = Path(f"{self.input.stem}_{self.encoder}{suffix}")
|
||||||
|
|
||||||
|
def promt_output_overwrite(self):
|
||||||
|
|
||||||
|
if self.output_file.exists():
|
||||||
|
print(
|
||||||
|
f":: Output file {self.output_file} exist, overwrite? [y/n or enter]:"
|
||||||
|
)
|
||||||
|
|
||||||
|
promt = input()
|
||||||
|
|
||||||
|
if "y" in promt.lower() or promt.strip() == "":
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
print("Stopping")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
def load_project_from_file(self, path_string):
|
def load_project_from_file(self, path_string):
|
||||||
"""
|
"""
|
||||||
Loads projedt attributes from json to this class
|
Loads projedt attributes from json to this class
|
||||||
|
@ -202,7 +219,7 @@ class Project(object):
|
||||||
"""Creating temporally folders when needed."""
|
"""Creating temporally folders when needed."""
|
||||||
|
|
||||||
if self.temp:
|
if self.temp:
|
||||||
if self.temp[-1] in ('\\', '/'):
|
if self.temp[-1] in ("\\", "/"):
|
||||||
self.temp = Path(f"{self.temp}{'.' + str(hash_path(str(self.input)))}")
|
self.temp = Path(f"{self.temp}{'.' + str(hash_path(str(self.input)))}")
|
||||||
else:
|
else:
|
||||||
self.temp = Path(str(self.temp))
|
self.temp = Path(str(self.temp))
|
||||||
|
|
Loading…
Reference in a new issue