diff options
author | Lars Wirzenius <liw@liw.fi> | 2013-10-26 23:22:49 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2013-10-26 23:22:49 +0100 |
commit | 97755806efc52658a8eef434f3510fcc9e75d0b7 (patch) | |
tree | 9dc8332faa57506fa45059c52936e919bacf3eb8 | |
parent | 60b2da934adff81d1a76417294f98a5f11ed83b9 (diff) | |
download | jt-97755806efc52658a8eef434f3510fcc9e75d0b7.tar.gz |
Add new-person subcommand
-rwxr-xr-x | jt | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -223,4 +223,40 @@ class JournalTool(cliapp.Application): ['git', 'push', 'origin', 'HEAD'], cwd=self.settings['source']) + def cmd_new_person(self, args): + '''Create a page to list all notes referring to a person. + + This is probably only useful to Lars's personal journal. + + ''' + + if len(args) != 1: + raise cliapp.AppException( + 'Need the name of a person (in Last, First form)') + + def normalise(name): + s = name.lower() + s = ' '.join(s.split(',')) + s = '.'.join(s.split()) + return s + + name = args[0] + basename = normalise(name) + pathname = os.path.join( + self.settings['source'], 'people', basename + '.mdwn') + + if os.path.exists(pathname): + raise cliapp.AppException('File %s already exists' % pathname) + + with open(pathname, 'w') as f: + f.write('''\ +[[!meta title="%(name)s"]] + +[[!inline archive=yes pages="link(people/%(basename)s)"]] +''' % + { + 'name': name, + 'basename': basename, + }) + JournalTool().run() |