Skip to content

Commit

Permalink
Use a new configuration entry to determine the extension for the temp…
Browse files Browse the repository at this point in the history
… file using the title as input

(#11)
  • Loading branch information
scbtest committed May 5, 2014
1 parent 1370534 commit f8c5919
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion quick_simplenote.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,24 @@ def open_note(note):
sublime.active_window().open_file(filepath)

def get_filename_for_note(note):
# Take out invalid characters from title and use that as base for the name
import string
valid_chars = "-_.() %s%s" % (string.ascii_letters, string.digits)
note_name = get_note_name(note)
base = ''.join(c for c in note_name if c in valid_chars)
return base + ' (' + note['key'] + ')'
# Determine extension based on title
extension_map = settings.get('title_extension_map')
extension = ''
if extension_map:
for item in extension_map:
import re
if re.search(note_name, item['title_regex']):
extension = '.' + item['extension']
break

print extension_map

return base + ' (' + note['key'] + ')' + extension

def get_path_for_note(note):
return path.join(temp_path, get_filename_for_note(note))
Expand Down

0 comments on commit f8c5919

Please sign in to comment.