Skip to content

Commit

Permalink
Way to set note extension
Browse files Browse the repository at this point in the history
If note title has extension and it present in "note_file_extensions" list, than it used instead of  "note_save_extension".
  • Loading branch information
Playermet committed May 19, 2015
1 parent 876546e commit 24be25d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,11 @@ def create_note(self, title):
if not os.path.exists(directory):
os.makedirs(directory)

ext = "." + settings().get("note_save_extension")
if any(title.endswith("." + ext) for ext in settings().get("note_file_extensions")):
ext = ""
else:
ext = "." + settings().get("note_save_extension")

file = os.path.join(directory, title + ext)
if not os.path.exists(file):
open(file, 'w+').close()
Expand Down Expand Up @@ -332,7 +336,11 @@ def rename_note(self, title):
if not os.path.exists(directory):
os.makedirs(directory)

ext = "." + settings().get("note_save_extension")
if any(title.endswith("." + ext) for ext in settings().get("note_file_extensions")):
ext = ""
else:
ext = "." + settings().get("note_save_extension")

new_file_path = os.path.join(directory, title + ext)
# pardir = os.path.abspath(os.path.join(self.file_path, '..'))
if not os.path.isfile(new_file_path):
Expand Down

0 comments on commit 24be25d

Please sign in to comment.