Skip to content

Commit

Permalink
start of a "doc" plugin that unifies all documentation - implemented …
Browse files Browse the repository at this point in the history
…"moa blog" [#7]
  • Loading branch information
mfiers committed Apr 1, 2011
1 parent a57d235 commit fa8bcfa
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions lib/python/moa/plugin/doc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Copyright 2009-2011 Mark Fiers
# The New Zealand Institute for Plant & Food Research
#
# This file is part of Moa - http://github.com/mfiers/Moa
#
# Licensed under the GPL license (see 'COPYING')
#
"""
**doc** - Manage job documentation
----------------------------------
Manage project / title / description for jobs
"""

import getpass
import datetime

import moa.ui
import moa.utils
import moa.logger as l

def defineCommands(data):
"""
Set the moa commands for this plugin
"""
data['commands']['blog'] = {
'desc' : 'record a short note',
'usage' : 'moa blog',
'call' : blog,
'needsJob' : True,
'log' : True
}


def blog(data):
"""
Allows a user to enter a short note that is appended to
moa.description (including a timestamp). Use it as follows::
$ moa blog
Here you can enter a short, conscise, multi-
line message describing what you have been
doing
[ctrl-d]
Note: the ctrl-d needs to be given on an empty line. The text is
appended to moa.desciption. In the web interface this is converted
to Markdown_.
.. _Markdown: http://daringfireball.net/projects/markdown/ markdown.
"""
job = data['job']
moa.utils.moaDirOrExit(job)

txt = []
while True:
try:
line = raw_input("")
txt.append(line)
except (EOFError, KeyboardInterrupt):
break

message = "\n".join(txt)
with open('moa.description', "a") as F:
now = datetime.datetime.now()
F.write("\n")
header = "%s - %s writes::" % (
now.isoformat(" "), getpass.getuser())
F.write("%s\n" % header)
F.write("%s\n" % ("=" * len(header)))
F.write(message)
F.write("\n")

0 comments on commit fa8bcfa

Please sign in to comment.