Skip to content

Commit

Permalink
Merge pull request #25 from Playermet/patch-1
Browse files Browse the repository at this point in the history
Way to set note extension
  • Loading branch information
fk128 committed May 30, 2015
2 parents 876546e + 24be25d commit 1f5c5c2
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 1f5c5c2

Please sign in to comment.