<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>noorul islam :: my thoughts &#187; python</title>
	<atom:link href="http://noorul.com/blog/category/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://noorul.com/blog</link>
	<description>gnu/linux, emacs and random thoughts</description>
	<lastBuildDate>Wed, 01 Aug 2012 02:24:06 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.1</generator>
		<item>
		<title>Orgmode &#8211; Generate custom report using external python script.</title>
		<link>http://noorul.com/blog/2010/07/18/orgmode-generate-custom-report-using-external-python-script/</link>
		<comments>http://noorul.com/blog/2010/07/18/orgmode-generate-custom-report-using-external-python-script/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 04:09:23 +0000</pubDate>
		<dc:creator>noorul</dc:creator>
				<category><![CDATA[debian]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[orgmode]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://noorul.com/blog/?p=78</guid>
		<description><![CDATA[I use orgmode in emacs as a to-do list manager. End of every week I send my status report to the team. Earlier I used to do this manually by going through the agenda for the week and collecting relevant information. I thought of automating it since this is repeated every week. It was super [...]]]></description>
			<content:encoded><![CDATA[<p>I use <a href="http://orgmode.org">orgmode</a> in emacs as a to-do list manager. End of every week I send my status report to the team. Earlier I used to do this manually by going through the agenda for the week and collecting relevant information. I thought of automating it since this is repeated every week. </p>
<p>It was super easy for me because, I strictly associate each task with a corresponding tag to uniquely identify it. These tags are related to my office projects and the script is a custom one which suits my requirement. </p>
<p>Here is the emacs part.</p>
<pre>
(defun noorul/gen_weekly_report (startPos endPos)
  "Generate weekly report using external pythong script"
(interactive "r")
  (let (scriptName)
    (setq scriptName "~/work/python/gen_weekly_report.py")
    (shell-command-on-region startPos endPos scriptName "*Weekly Report*" 
			     nil nil t)
    ))

(global-set-key (kbd "&lt;f6&gt; r") 'noorul/gen_weekly_report)
</pre>
<p>Here is the python supporting script.</p>
<pre>
#!/usr/bin/env python
import sys
import re

report_dict = {}
cubit_issue_id_regex = re.compile('.*(cubit\d+):.*$')
artf_issue_id_regex = re.compile('.*(artf\d+):.*$')
issue_desc_regex = re.compile('.*(WAITING|DONE|NEXT) (.*) :.*$')
for line in sys.stdin.readlines():
    id_match = re.match(cubit_issue_id_regex, line)
    if not id_match:
        id_match = re.match(artf_issue_id_regex, line)
    if id_match:
        issue = id_match.groups()[0]
        issue_desc = ''
        desc_match = re.match(issue_desc_regex, line)
        if desc_match:
            issue_desc = desc_match.groups()[1]
            if issue not in report_dict.keys():
                report_dict[issue] = issue_desc

print 'This Week:\n'
for issue in sorted(report_dict.keys()):
    print '* %-10s: %s' % (issue,  report_dict[issue])
</pre>
<p>Now to collect my report, all what I have to do is, go to the agenda buffer switch to log mode and mark the week area and press &#8216;F6 r&#8217;.</p>
<p>I think I can avoid the region marking step and that will be an enhancement.</p>
]]></content:encoded>
			<wfw:commentRss>http://noorul.com/blog/2010/07/18/orgmode-generate-custom-report-using-external-python-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
