-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start of a "doc" plugin that unifies all documentation - implemented …
…"moa blog" [#7]
- Loading branch information
Showing
1 changed file
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |