Skip to content

Commit

Permalink
Merge pull request #2 from cjj1977/multiple-style-files
Browse files Browse the repository at this point in the history
Ignore "do not save" styles
  • Loading branch information
Charlie Joynt authored Nov 7, 2023
2 parents 39b707b + 362be28 commit 1d92909
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions modules/styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def reload(self):
for file in os.listdir(path):
if fnmatch.fnmatch(file, fileglob):
self.styles[file.upper()] = PromptStyle(
f"{file.upper()}", None, None, "divider"
f"{file.upper()}", None, None, "do_not_save"
)
self.load_from_csv(os.path.join(path, file))
elif not os.path.exists(self.path):
Expand Down Expand Up @@ -165,6 +165,9 @@ def save_styles(self, path: str = None) -> None:
if style.path:
style_paths.add(style.path)

# Remove any paths for styles that are just list dividers
style_paths.remove("do_not_save")

csv_names = [os.path.split(path)[1].lower() for path in style_paths]

for style_path in style_paths:
Expand All @@ -178,8 +181,6 @@ def save_styles(self, path: str = None) -> None:
writer.writeheader()
for style in (s for s in self.styles.values() if s.path == style_path):
# Skip style list dividers, e.g. "STYLES.CSV"
if style.path.lower() == "divider":
continue
if style.name.lower().strip("# ") in csv_names:
continue
# Write style fields, ignoring the path field
Expand Down

0 comments on commit 1d92909

Please sign in to comment.