summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2014-09-22 16:29:39 +0100
committerLars Wirzenius <liw@liw.fi>2014-09-22 16:29:39 +0100
commita3e43a132c2fa0df03a1b87b45cc21c4ed35f4d0 (patch)
tree9a3c269d4bf7215254c71ac5286da45b957fdc9f
parentd61cf7d0428ec5428667e315edc530202bcd4bda (diff)
downloadjt-a3e43a132c2fa0df03a1b87b45cc21c4ed35f4d0.tar.gz
Make better filenames
-rwxr-xr-xjt16
1 files changed, 14 insertions, 2 deletions
diff --git a/jt b/jt
index bf62219..8facee5 100755
--- a/jt
+++ b/jt
@@ -20,6 +20,7 @@ import optparse
import os
import re
import shutil
+import string
import subprocess
import sys
import tempfile
@@ -243,15 +244,26 @@ class JournalTool(cliapp.Application):
if self.settings['layout'] in ('liw', 'ct'):
basename = time.strftime('%Y-%m-%d-%H:%M:%S')
elif self.settings['layout'] == 'pkb':
- basename = self.get_draft_title(draft_mdwn)
- if not basename:
+ title = self.get_draft_title(draft_mdwn)
+ if not title:
raise Exception("%s has no title" % draft_mdwn)
+ basename = self.summarise_title(title)
else:
raise Exception(
'Setting --layout=%s is unknown' % self.settings['layout'])
return basename
+ def summarise_title(self, title):
+ basename = ''
+ acceptable = set(string.ascii_letters + string.digits + '-_')
+ for c in title.lower():
+ if c in acceptable:
+ basename += c
+ elif not basename.endswith('_'):
+ basename += '_'
+ return basename
+
def cmd_new_person(self, args):
'''Create a page to list all notes referring to a person.