mirror of
https://github.com/imarkoff/Marble-shell-theme.git
synced 2025-09-16 16:28:39 -07:00
Fix file handling issues that breaks GDM theme
This commit is contained in:
@@ -156,8 +156,8 @@ class Theme:
|
|||||||
:param content: content to add
|
:param content: content to add
|
||||||
"""
|
"""
|
||||||
|
|
||||||
with open(self.main_styles, 'r+') as main_styles:
|
with open(self.main_styles, 'r') as main_styles:
|
||||||
main_content = main_styles.read()
|
main_content = main_styles.read()
|
||||||
|
|
||||||
main_styles.seek(0)
|
with open(self.main_styles, 'w') as main_styles:
|
||||||
main_styles.write(content + '\n' + main_content)
|
main_styles.write(content + '\n' + main_content)
|
||||||
|
@@ -157,8 +157,10 @@ def label_files(directory, label, *args):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# Open all files
|
# Open all files
|
||||||
files = [open(file, 'r+') for file in args]
|
files = [open(file, 'r') for file in args]
|
||||||
read_files = [file.read() for file in files]
|
read_files = []
|
||||||
|
|
||||||
|
filenames = []
|
||||||
|
|
||||||
for filename in os.listdir(directory):
|
for filename in os.listdir(directory):
|
||||||
# Skip if the file is already labeled
|
# Skip if the file is already labeled
|
||||||
@@ -172,13 +174,19 @@ def label_files(directory, label, *args):
|
|||||||
new_filename = f"{name}-{label}{extension}"
|
new_filename = f"{name}-{label}{extension}"
|
||||||
os.rename(os.path.join(directory, filename), os.path.join(directory, new_filename))
|
os.rename(os.path.join(directory, filename), os.path.join(directory, new_filename))
|
||||||
|
|
||||||
# Replace the filename in all files
|
filenames.append((filename, new_filename))
|
||||||
for file in read_files:
|
|
||||||
file.replace(filename, new_filename)
|
# Replace the filename in all files
|
||||||
|
for i, file in enumerate(files):
|
||||||
|
read_file = file.read()
|
||||||
|
read_file.replace(filenames[i][0], filenames[i][1])
|
||||||
|
read_files.append(read_file)
|
||||||
|
file.close()
|
||||||
|
|
||||||
|
write_files = [open(file, 'w') for file in args]
|
||||||
|
|
||||||
# Write the changes to the files and close them
|
# Write the changes to the files and close them
|
||||||
for i, file in enumerate(files):
|
for i, file in enumerate(write_files):
|
||||||
file.seek(0)
|
|
||||||
file.write(read_files[i])
|
file.write(read_files[i])
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
@@ -192,7 +200,7 @@ def remove_properties(file, *args):
|
|||||||
|
|
||||||
new_content = ""
|
new_content = ""
|
||||||
|
|
||||||
with open(file, "r+") as read_file:
|
with open(file, "r") as read_file:
|
||||||
content = read_file.read()
|
content = read_file.read()
|
||||||
|
|
||||||
for line in content.splitlines():
|
for line in content.splitlines():
|
||||||
@@ -201,8 +209,8 @@ def remove_properties(file, *args):
|
|||||||
elif "}" in line:
|
elif "}" in line:
|
||||||
new_content += "}\n"
|
new_content += "}\n"
|
||||||
|
|
||||||
read_file.seek(0)
|
with open(file, "w") as write_file:
|
||||||
read_file.write(new_content)
|
write_file.write(new_content)
|
||||||
|
|
||||||
|
|
||||||
def remove_keywords(file, *args):
|
def remove_keywords(file, *args):
|
||||||
@@ -212,12 +220,11 @@ def remove_keywords(file, *args):
|
|||||||
:param args: keywords to remove
|
:param args: keywords to remove
|
||||||
"""
|
"""
|
||||||
|
|
||||||
with open(file, "r+") as read_file:
|
with open(file, "r") as read_file:
|
||||||
content = read_file.read()
|
content = read_file.read()
|
||||||
|
|
||||||
for arg in args:
|
for arg in args:
|
||||||
content = content.replace(arg, "")
|
content = content.replace(arg, "")
|
||||||
|
|
||||||
read_file.seek(0)
|
with open(file, "w") as write_file:
|
||||||
read_file.write(content)
|
write_file.write(content)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user