-
Notifications
You must be signed in to change notification settings - Fork 1
fixing for the above bug in windows #3
Description
Step - 1:
def change_rx_config_details():
dir_name = os.path.basename(os.getcwd()) # changed
for file in os.listdir(os.getcwd()):
if file == "rxconfig.py":
file_path = os.path.join(os.getcwd(), file)
with open(file_path, "r") as rder:
config = rder.read()
config = config.replace(f"{dir_name}", "app")
with open(file_path, "w") as wter:
wter.write(config)
remove_folder = os.path.join(os.getcwd(), dir_name)
shutil.rmtree(remove_folder)
Step - 2:
def create_src_file_structure():
source = os.path.join(Path(file).parent.parent, "app")
replicate = Path("./app")
def create_dir_file_structure(dir_path: str, key: str, files):
os.makedirs(dir_path,exist_ok=True)
for file in files:
source_path = os.path.join(source, key, file)
replicate_path = os.path.join(dir_path, file)
if os.path.exists(source_path):
with open(source_path, "r") as src_file, open(replicate_path, "w") as dst_file:
dst_file.write(src_file.read())
else:
os.makedirs(os.path.dirname(replicate_path), exist_ok=True) # Create directory if it doesn't exist
with open(replicate_path, "w") as dst_file:
pass # Create an empty file
for key, value in file_structure.items():
if value is not None:
dir_path = os.path.join(replicate, key)
if isinstance(value, list):
create_dir_file_structure(dir_path, key, value)
else:
source_file = os.path.join(source, key)
file_path = os.path.join(replicate, key)
if os.path.exists(source_file):
with open(source_file, "r") as src_file, open(file_path, "w") as dst_file:
dst_file.write(src_file.read())
else:
os.makedirs(os.path.dirname(file_path), exist_ok=True) # Create directory if it doesn't exist
with open(file_path, "w") as dst_file:
pass # Create an empty file