summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/journal-note11
1 files changed, 7 insertions, 4 deletions
diff --git a/scripts/journal-note b/scripts/journal-note
index 3cd7b78..ed87a79 100755
--- a/scripts/journal-note
+++ b/scripts/journal-note
@@ -68,6 +68,9 @@ class App(object):
def drafts(self, opts):
return os.path.join(opts.base, 'drafts')
+ def draftname(self, opts, draft_id):
+ return os.path.join(opts.base, 'drafts', '%s.mdwn' % draft_id)
+
def gedit_file(self, pathname):
subprocess.check_call(['gedit', '--new-window', pathname])
@@ -76,7 +79,7 @@ class App(object):
raise AppException('Usage: journal-note new TITLE')
for i in range(1000):
- name = os.path.join(opts.base, 'drafts', '%d.mdwn' % i)
+ name = self.draftname(opts, i)
if not os.path.exists(name):
break
else:
@@ -110,7 +113,7 @@ class App(object):
def edit_entry(self, args, opts):
if not args:
raise AppException('Usage: journal-note edit ID')
- pathname = os.path.join(self.drafts(opts), args[0] + '.mdwn')
+ pathname = self.draftname(opts, args[0])
if not os.path.exists(pathname):
raise AppException('draft %s does not exist' % args[0])
self.gedit_file(pathname)
@@ -118,13 +121,13 @@ class App(object):
def remove_entry(self, args, opts):
if not args:
raise AppException('Usage: journal-note remove ID')
- pathname = os.path.join(self.drafts(opts), args[0] + '.mdwn')
+ pathname = self.draftname(opts, args[0])
os.remove(pathname)
def finish_entry(self, args, opts):
if not args:
raise AppException('Usage: journal-note finish ID')
- draft = os.path.join(self.drafts(opts), args[0] + '.mdwn')
+ draft = self.draftname(opts, args[0])
if not os.path.exists(draft):
raise AppException('draft %s does not exist' % args[0])
basename = time.strftime('%Y-%m-%d-%H:%M.mdwn')