Skip to content

Commit

Permalink
Merge pull request #28 from OpenGOAL-Unofficial-Mods/fix-missing-pcke…
Browse files Browse the repository at this point in the history
…rnel

check if file exists before changing text
  • Loading branch information
Zedb0T authored Jul 16, 2023
2 parents e1883ba + 661e8aa commit 1b87ffa
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions utils/launcherUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,34 +214,24 @@ def reinstall(MOD_ID):


def replaceText(path, search_text, replace_text):
# creating a variable and storing the discord RPC text,
# if the mod has changed this then we leave it as the modder wanted.
# that we want to search

# creating a variable and storing the mod name we want to display
# in discord RPC
# Check if the file exists
if not os.path.isfile(path):
print(f"File '{path}' does not exist.")
return

# Opening our pckernel file in read only
# mode using the open() function
# Open the file in read-only mode
with open(path, "r") as file:

# Reading the content of the pckernel file
# using the read() function and storing
# them in a new variable
data = file.read()

# Searching and replacing the text
# using the replace() function
data = data.replace(search_text, replace_text)
# Perform the search and replace operation
data = data.replace(search_text, replace_text)

# Opening our pckernel file in write only
# mode to write the replaced content
# Open the file in write mode to write the replaced content
with open(path, "w") as file:

# Writing the replaced data in our
# pckernel file
file.write(data)

print(f"Text replaced successfully in file '{path}'.")


def launch(URL, MOD_ID, MOD_NAME, LINK_TYPE):
if URL is None:
Expand Down

0 comments on commit 1b87ffa

Please sign in to comment.