mirror of
https://github.com/imarkoff/Marble-shell-theme.git
synced 2025-09-17 16:57:56 -07:00
Add ability to set theme globally
This commit is contained in:
@@ -145,3 +145,39 @@ def hex_to_rgba(hex_color):
|
||||
int(hex_color[2:4], 16), \
|
||||
int(hex_color[4:6], 16), \
|
||||
int(hex_color[6:8], 16) / 255
|
||||
|
||||
|
||||
def label_files(directory, label, *args):
|
||||
"""
|
||||
Add a label to all files in a directory
|
||||
:param directory: folder where files are located
|
||||
:param label: label to add
|
||||
:param args: files to change links to labeled files
|
||||
:return:
|
||||
"""
|
||||
|
||||
# Open all files
|
||||
files = [open(file, 'r+') for file in args]
|
||||
read_files = [file.read() for file in files]
|
||||
|
||||
for filename in os.listdir(directory):
|
||||
# Skip if the file is already labeled
|
||||
if label in filename:
|
||||
continue
|
||||
|
||||
# Split the filename into name and extension
|
||||
name, extension = os.path.splitext(filename)
|
||||
|
||||
# Form the new filename and rename the file
|
||||
new_filename = f"{name}-{label}{extension}"
|
||||
os.rename(os.path.join(directory, filename), os.path.join(directory, new_filename))
|
||||
|
||||
# Replace the filename in all files
|
||||
for file in read_files:
|
||||
file.replace(filename, new_filename)
|
||||
|
||||
# Write the changes to the files and close them
|
||||
for i, file in enumerate(files):
|
||||
file.seek(0)
|
||||
file.write(read_files[i])
|
||||
file.close()
|
||||
|
Reference in New Issue
Block a user