summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2014-11-22 18:24:32 +0200
committerLars Wirzenius <liw@liw.fi>2014-11-22 18:24:32 +0200
commita94a0fb1e26b926cffec54ddfa84dc8f71720b80 (patch)
tree2898852aec56b7b26e3a648820c29472457c6392
parent70608dbf368a54be4d40c8e3fe6bfa179dd6e12f (diff)
downloadjt-a94a0fb1e26b926cffec54ddfa84dc8f71720b80.tar.gz
Move published_dir into FinishCommand
-rwxr-xr-xjt26
1 files changed, 13 insertions, 13 deletions
diff --git a/jt b/jt
index 74673be..0b12ff9 100755
--- a/jt
+++ b/jt
@@ -131,14 +131,14 @@ class FinishCommand(Command):
assert ext == '.mdwn'
pub_attch = os.path.join(
- self._app.published_dir(), self._app.published_basename(draft_mdwn))
+ self.published_dir(), self._app.published_basename(draft_mdwn))
pub_mdwn = pub_attch + '.mdwn'
if os.path.exists(pub_mdwn):
raise cliapp.AppException('%s already exists' % pub_mdwn)
- if not os.path.exists(self._app.published_dir()):
- os.makedirs(self._app.published_dir())
+ if not os.path.exists(self.published_dir()):
+ os.makedirs(self.published_dir())
os.rename(draft_mdwn, pub_mdwn)
if os.path.exists(draft_attch):
os.rename(draft_attch, pub_attch)
@@ -156,6 +156,16 @@ class FinishCommand(Command):
['git', 'push', 'origin', 'HEAD'],
cwd=self._app.settings['source'])
+ def published_dir(self):
+ subdirs = {
+ 'liw': 'notes',
+ 'ct': 'log/%d' % time.localtime().tm_year,
+ 'pkb': time.strftime('notes/%Y/%m/%d'),
+ }
+
+ subdir = subdirs[self._app.settings['layout']]
+ return os.path.join(self._app.settings['source'], subdir)
+
class NewPersonCommand(Command):
@@ -304,16 +314,6 @@ class JournalTool(cliapp.Application):
'''Publish a draft journal entry.'''
FinishCommand(self).run(args)
- def published_dir(self):
- subdirs = {
- 'liw': 'notes',
- 'ct': 'log/%d' % time.localtime().tm_year,
- 'pkb': time.strftime('notes/%Y/%m/%d'),
- }
-
- subdir = subdirs[self.settings['layout']]
- return os.path.join(self.settings['source'], subdir)
-
def published_basename(self, draft_mdwn):
if self.settings['layout'] in ('liw', 'ct'):
basename = time.strftime('%Y-%m-%d-%H:%M:%S')