Skip to content
This repository has been archived by the owner on Feb 10, 2024. It is now read-only.

fixing for the above bug in windows #3

Open
nssnaresh5 opened this issue Sep 14, 2023 · 0 comments
Open

fixing for the above bug in windows #3

nssnaresh5 opened this issue Sep 14, 2023 · 0 comments

Comments

@nssnaresh5
Copy link

nssnaresh5 commented Sep 14, 2023

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant