Conversion_Kitchen_Code/kitchen_counter/conversion/subtitling/base.py

37 lines
971 B
Python
Raw Permalink Normal View History

2024-04-27 09:33:09 +00:00
# Python program to explain os.makedirs() method
# importing os module
import os
# os.makedirs() method will raise
# an OSError if the directory
# to be created already exists
# But It can be suppressed by
# setting the value of a parameter
# exist_ok as True
# Directory
def make_directory(directory):
# Parent Directory path
# parent_dir = "/home/user/mnf/project/MNF/conversion/subtitling"
# Path
# path = os.path.join(parent_dir, directory)
# Create the directory
# 'Nikhil'
try:
os.makedirs(directory, mode=0o777, exist_ok=True)
print("Directory '%s' created successfully" % directory)
return directory
except OSError as error:
print("Directory '%s' can not be created" % directory)
# By setting exist_ok as True
# error caused due already
# existing directory can be suppressed
# but other OSError may be raised
# due to other error like
# invalid path name