<?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>Andrew Channels Dexter Pinion</title>
	<atom:link href="http://halfcooked.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://halfcooked.com/blog</link>
	<description>Wherein I write some stuff  that you may like to read. Or not, its up to you really.</description>
	<lastBuildDate>Sat, 26 Nov 2011 04:45:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Extracting a discrete set of values</title>
		<link>http://halfcooked.com/blog/2011/11/10/extracting-a-discrete-set-of-values/</link>
		<comments>http://halfcooked.com/blog/2011/11/10/extracting-a-discrete-set-of-values/#comments</comments>
		<pubDate>Thu, 10 Nov 2011 05:42:25 +0000</pubDate>
		<dc:creator>Andy Todd</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://halfcooked.com/blog/?p=163</guid>
		<description><![CDATA[Today&#8217;s I love Python moment is bought to you by set types. I have a file, XML naturally, the contains a series of transactions. Each transaction has a reference number, but the reference number may be repeated. I want to pull the distinct set of reference numbers from this file. The way I learnt to [...]]]></description>
			<content:encoded><![CDATA[<p>Today&#8217;s I love Python moment is bought to you by <a href="http://docs.python.org/library/stdtypes.html#set-types-set-frozenset">set type</a>s.</p>
<p>I have a file, XML naturally, the contains a series of transactions. Each transaction has a reference number, but the reference number may be repeated. I want to pull the distinct set of reference numbers from this file. The way I learnt to build up a discrete set of items (many years ago) was to use a dict and set default.</p>
<pre>
>>> ref_nos = {}
>>> for record in records:
>>>     ref_nos.setdefault(record.key, 1)
>>> ref_nos.keys()
</pre>
<p>But Python has had a sets module since 2.3 and the set standard data type since 2.6 so my knowledge is woefully out of date. The latest way to get the unique values from a sequence looks something like this;</p>
<p><code>>>> ref_nos = set([record.key for record in records])</code></p>
<p>I think I should get bonus points for using a list comprehension as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://halfcooked.com/blog/2011/11/10/extracting-a-discrete-set-of-values/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Validating an XML File with LXML</title>
		<link>http://halfcooked.com/blog/2011/08/19/validating-an-xml-file-with-lxml/</link>
		<comments>http://halfcooked.com/blog/2011/08/19/validating-an-xml-file-with-lxml/#comments</comments>
		<pubDate>Fri, 19 Aug 2011 10:35:27 +0000</pubDate>
		<dc:creator>Andy Todd</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://halfcooked.com/blog/?p=158</guid>
		<description><![CDATA[I&#8217;ve been playing with XML files recently and have on the odd occasion needed to validate a file against an XML schema. This is surprisingly easy using lxml, the Swiss Army knife of Python XML processing. Allow me to demonstrate. &#62;&#62;&#62; from lxml import etree &#62;&#62;&#62; schema = etree.XMLSchema(etree.parse('schema_file_name.xsd')) &#62;&#62;&#62; xml_file = etree.parse('xml_file_name.xml') &#62;&#62;&#62; schema.validate(xml_file) [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been playing with XML files recently and have on the odd occasion needed to validate a file against an <a href="http://www.w3.org/XML/Schema">XML schema</a>. This is surprisingly easy using <a href="http://lxml.de/">lxml</a>, the Swiss Army knife of Python XML processing. Allow me to demonstrate.</p>
<p><code><br />
&gt;&gt;&gt; from lxml import etree<br />
&gt;&gt;&gt; schema = etree.XMLSchema(etree.parse('schema_file_name.xsd'))<br />
&gt;&gt;&gt; xml_file = etree.parse('xml_file_name.xml')<br />
&gt;&gt;&gt; schema.validate(xml_file)<br />
True<br />
</code></p>
<p>Job done. If you are unlucky enough that your file doesn&#8217;t validate you can find out by checking the <tt>error_log</tt> attribute of your XMLSchema object.</p>
<p>&nbsp;</p>
<div id="level" style="display: none;">Need test? Find more about <a href="http://www.atotaldetox.com/"><strong>passing drug test</strong></a>.</div>
]]></content:encoded>
			<wfw:commentRss>http://halfcooked.com/blog/2011/08/19/validating-an-xml-file-with-lxml/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Freedom</title>
		<link>http://halfcooked.com/blog/2011/06/23/freedom/</link>
		<comments>http://halfcooked.com/blog/2011/06/23/freedom/#comments</comments>
		<pubDate>Thu, 23 Jun 2011 06:47:39 +0000</pubDate>
		<dc:creator>Andy Todd</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://halfcooked.com/blog/?p=156</guid>
		<description><![CDATA[Due to a recent accounting error (on my part and in my favour) I recently found myself in possession of a netbook. I know that makes me a luddite and I should have bought a tablet. Call me a throwback. In my defence it was half the price of an iPad and a lot more [...]]]></description>
			<content:encoded><![CDATA[<p>Due to a recent accounting error (on my part and in my favour) I recently found myself in possession of a netbook. I know that makes me a luddite and I should have bought a tablet. Call me a throwback. In my defence it was half the price of an iPad and a lot more practical for me. The major deal breaker for me is that iPad&#8217;s don&#8217;t come with a command line client and can&#8217;t (to the best of my knowledge) run <a href="http://www.vim.org/">the only editor worth having</a>. Also, iPad&#8217;s don&#8217;t run <a href="http://diveintomark.org/archives/2004/05/14/freedom-0">free software</a> and that is becoming more important to me. So I bought a netbook.</p>
<p>As it came with Windows installed my first task was to install a decent operating system. I&#8217;m a fan of <a href="http://www.xubuntu.org/">Xubuntu</a> so I grabbed the latest release and then &#8230; stopped. Because my first thought was to burn the Xubuntu .iso file to a disk and install from that, but my netbook doesn&#8217;t have a CD drive. I&#8217;ve never installed from anything else in the past so I was a bit stuck.</p>
<p>The good news is that it is 2011 and Google came to the rescue. After a couple of false turns, and via <a href="http://www.pendrivelinux.com/">Pendrivelinux.com</a>, I found the rather wonderful <a href="http://www.linuxliveusb.com/en/home">LinuxLive USB Creator</a>. Whilst it isn&#8217;t an exhaustive test, and don&#8217;t come to me with your problems, I simply installed and started LiLi, pointed it at my USB stick and the .iso file I had downloaded and 10 minutes later I had a bootable copy of Xubuntu.</p>
<p>Some words of praise, too, for the (X)ubuntu installer folks who have made getting their operating system on a new machine a complete breeze. Thanks everyone, top job.</p>
<p>Now all I&#8217;ve got to do is install all of the software that I rely on, configure the thing and I can start using it. At my pace that should only take a week or two. I&#8217;ll be back then.</p>
]]></content:encoded>
			<wfw:commentRss>http://halfcooked.com/blog/2011/06/23/freedom/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use the right tool for the job</title>
		<link>http://halfcooked.com/blog/2010/11/24/use-the-right-tool-for-the-job/</link>
		<comments>http://halfcooked.com/blog/2010/11/24/use-the-right-tool-for-the-job/#comments</comments>
		<pubDate>Wed, 24 Nov 2010 03:28:16 +0000</pubDate>
		<dc:creator>Andy Todd</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://halfcooked.com/blog/?p=152</guid>
		<description><![CDATA[I was going to write an informed and opinionated piece about the use of proper tools in corporate IT departments. In particular I was going to say that I found it interesting that smaller, more cost conscious teams (in startups or open source projects) use more modern and sophisticated tools for issue management, project planning [...]]]></description>
			<content:encoded><![CDATA[<p>I was going to write an informed and opinionated piece about the use of proper tools in corporate IT departments. In particular I was going to say that I found it interesting that smaller, more cost conscious teams (in  startups or open source projects) use more modern and sophisticated tools for issue management, project planning and code management than the big IT departments that I have the pleasure to work in.</p>
<p>But, well, I&#8217;ve got to go and write a status report showing the break down of issues by status, and that is going to take me about three and a half hours. So I don&#8217;t have time to faff about on my blog.</p>
<p>Instead, I&#8217;ll just paraphrase <a href="http://www.jwz.org/">JWZ</a> (who was <a href="http://regex.info/blog/2006-09-15/247">apparently</a> in turn paraphrasing an <a href="http://regex.info/blog/2006-09-15/247#comment-3085">older comment about sed</a>) and say;</p>
<blockquote><p>Some people, when confronted with a problem think &#8220;I know, I&#8217;ll use a SharePoint list.&#8221; Now they have two problems.</p></blockquote>
<p>I mean, a SharePoint list for issue management? When we could use <a href="http://www.atlassian.com/software/jira/">Jira</a> or <a href="http://www.fogcreek.com/fogbugz/">FogBugz</a>? I give up.</p>
]]></content:encoded>
			<wfw:commentRss>http://halfcooked.com/blog/2010/11/24/use-the-right-tool-for-the-job/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Gerald release 0.4.1</title>
		<link>http://halfcooked.com/blog/2010/10/26/gerald-release-0-4-1/</link>
		<comments>http://halfcooked.com/blog/2010/10/26/gerald-release-0-4-1/#comments</comments>
		<pubDate>Tue, 26 Oct 2010 01:45:43 +0000</pubDate>
		<dc:creator>Andy Todd</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://halfcooked.com/blog/?p=150</guid>
		<description><![CDATA[Before starting on some of the big changes planned for version 0.5, and thanks to patches and suggestions from various people I&#8217;ve addressed a couple of issues with Gerald 0.4. This means that we now have release Gerald 0.4.1 What&#8217;s new in this release? Not much, just some bug fixes, documentation changes and (hopefully) an [...]]]></description>
			<content:encoded><![CDATA[<p>Before starting on some of the big changes planned for version 0.5, and thanks to patches and suggestions from various people I&#8217;ve addressed a couple of issues with Gerald 0.4. This means that we now have release <a href="http://pypi.python.org/pypi/gerald/0.4.1">Gerald 0.4.1</a></p>
<p>What&#8217;s new in this release? Not much, just some bug fixes, documentation changes and (hopefully) an egg that is installable on all platforms. The .egg files available from PyPI (and soon to be available on SourceForge) should install without any errors and if my testing is correct will be usable on multiple platforms including Windows.</p>
<p>Downloads are available at the <a href="http://pypi.python.org/pypi/gerald/0.4.1">PyPI page</a> and the <a href="https://sourceforge.net/projects/halfcooked/files/">SourceForge project page</a>. As always, please send me an email with any problems or suggestions for improvement.</p>
]]></content:encoded>
			<wfw:commentRss>http://halfcooked.com/blog/2010/10/26/gerald-release-0-4-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python strftime reference</title>
		<link>http://halfcooked.com/blog/2010/08/20/python-strftime-reference/</link>
		<comments>http://halfcooked.com/blog/2010/08/20/python-strftime-reference/#comments</comments>
		<pubDate>Thu, 19 Aug 2010 23:23:47 +0000</pubDate>
		<dc:creator>Andy Todd</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://halfcooked.com/blog/?p=148</guid>
		<description><![CDATA[Take a look at this excellent single page web site &#8211; Python strftime reference. It does exactly what it says on the tin. Good work.]]></description>
			<content:encoded><![CDATA[<p>Take a look at this excellent single page web site &#8211; <a href="http://strftime.org/">Python strftime reference</a>. It does exactly what it says on the tin. Good work.</p>
]]></content:encoded>
			<wfw:commentRss>http://halfcooked.com/blog/2010/08/20/python-strftime-reference/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Gerald release 0.4</title>
		<link>http://halfcooked.com/blog/2010/06/27/gerald-release-0-4/</link>
		<comments>http://halfcooked.com/blog/2010/06/27/gerald-release-0-4/#comments</comments>
		<pubDate>Sun, 27 Jun 2010 05:36:17 +0000</pubDate>
		<dc:creator>Andy Todd</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://halfcooked.com/blog/?p=146</guid>
		<description><![CDATA[I&#8217;ve been revelling in the Python goodness this weekend at PyCon Australia. This has motivated me to fix the last couple of issues and then package and release Gerald 0.4 What&#8217;s new in this release? The most important changes are fixes to a number of issues identified by users of SQLPython. Gerald was appearing to [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been revelling in the <a href="http://www.python.org/">Python</a> goodness this weekend at <a href="http://pycon-au.org/2010">PyCon Australia</a>. This has motivated me to fix the last couple of issues and then package and release <a href="http://pypi.python.org/pypi/gerald/0.4.0">Gerald 0.4</a></p>
<p>What&#8217;s new in this release? The most important changes are fixes to a number of issues identified by users of <a href="http://pypi.python.org/pypi/sqlpython">SQLPython</a>. Gerald was appearing to take a long time to collect large schemas but was actually failing silently. I added test cases to show the problem and then fixed the code. This shouldn&#8217;t happen any more. </p>
<p>I applied a couple of patches supplied by <a href="http://catherinedevlin.blogspot.com/">Catherine Devlin</a> to cope with columns without defined lengths and to not get DBA objects in Oracle schemas.</p>
<p>I slipped in some new features as well; I implemented the <code>to_xml</code> and <code>compare</code> methods on the <code>CodeObject</code> class, and Gerald now supports views in MySQL (as long as you are running 5.1 or above).</p>
<p>Finally, I changed the project documentation to use <a href="http://sphinx.pocoo.org/">Sphinx</a>.</p>
<p>Downloads are available at the <a href="http://pypi.python.org/pypi/gerald/0.4.0">PyPI page</a> and the <a href="https://sourceforge.net/projects/halfcooked/files/">SourceForge project page</a>.</p>
<p>If you find any problems or want to contribute any code just send me an <a href="mailto:andy47@halfcooked.com">email</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://halfcooked.com/blog/2010/06/27/gerald-release-0-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generating HTML versions of reStructuredText files</title>
		<link>http://halfcooked.com/blog/2010/06/01/generating-html-versions-of-restructuredtext-files/</link>
		<comments>http://halfcooked.com/blog/2010/06/01/generating-html-versions-of-restructuredtext-files/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 03:37:32 +0000</pubDate>
		<dc:creator>Andy Todd</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://halfcooked.com/blog/?p=144</guid>
		<description><![CDATA[I wanted to quickly and easily convert a series of reStructured text documents into HTML equivalents. For reasons too dull to discuss here I couldn&#8217;t just use rst2html.py and didn&#8217;t want to go to the trouble of remembering enough bash syntax to write a shell script. So I thought that as long as docutils is [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to quickly and easily convert a series of <a href="http://docutils.sourceforge.net/rst.html">reStructured text</a> documents into HTML equivalents. For reasons too dull to discuss here I couldn&#8217;t just use <a href="http://docutils.sourceforge.net/docs/user/tools.html#rst2html-py">rst2html.py</a> and didn&#8217;t want to go to the trouble of remembering enough <a href="http://tldp.org/LDP/abs/html/">bash syntax</a> to write a shell script. </p>
<p>So I thought that as long as <a href="http://docutils.sourceforge.net/">docutils</a> is written in Python it would only take a moment or two to knock up a script to do what I needed. Well yes, and no. The script itself is fairly simple;</p>
<pre>
from docutils import core

def convert_files(name_pattern):
    for file_name in glob.glob(name_pattern):
        source = open(file_name, 'r')
        file_dest = file_name[:-4] + '.html'
        destination = open(file_dest, 'w')
        core.publish_file(source=source, destination=destination, writer_name='html')
        source.close()
        destination.close()
</pre>
<p>The most useful line being the one where I call <span class="inlinecode">core.publish_file</span>. But it wasn&#8217;t immediately obvious from the docutils documentation what series of incantations would achieve my desired results. Luckily, after some time spent perusing the documents I came across this <a href="http://docutils.sourceforge.net/docs/api/cmdline-tool.html">dissection</a> of rst2html.py. This, in turn, lead me to the description of the <a href="http://docutils.sourceforge.net/docs/api/publisher.html">Docutils Publisher</a>, which lists the convenience functions available to work with the engine.</p>
<p>The end result isn&#8217;t particularly elegant but it does get the job done and I thought I would share it in case anyone else has a similar need in the future.</p>
]]></content:encoded>
			<wfw:commentRss>http://halfcooked.com/blog/2010/06/01/generating-html-versions-of-restructuredtext-files/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Gerald release 0.3.6</title>
		<link>http://halfcooked.com/blog/2010/02/14/gerald-release-0-3-6/</link>
		<comments>http://halfcooked.com/blog/2010/02/14/gerald-release-0-3-6/#comments</comments>
		<pubDate>Sun, 14 Feb 2010 04:06:28 +0000</pubDate>
		<dc:creator>Andy Todd</dc:creator>
				<category><![CDATA[database]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://halfcooked.com/blog/?p=140</guid>
		<description><![CDATA[I have just released version 0.3.6 of Gerald. Gerald is a general purpose database schema toolkit written in Python. This release was at the request of the sqlpython project and contains only one change. A new convenience method connect has been added to the Schema class. This enables a schema to be initiated and then [...]]]></description>
			<content:encoded><![CDATA[<p>I have just released version 0.3.6 of <a href="http://halfcooked.com/code/gerald/">Gerald</a>. Gerald is a general purpose database schema toolkit written in <a href="http://www.python.org/">Python</a>.</p>
<p>This release was at the request of the <a href="http://pypi.python.org/pypi/sqlpython">sqlpython</a> project and contains only one change. A new convenience method <span class="inlinecode">connect</span> has been added to the <span class="inlinecode">Schema</span> class. This enables a schema to be initiated and then later have a database connection associated with it. Because this changes the public API of gerald I&#8217;ve released this under a new version number.</p>
<p>Development, bug and issue tracking and the project wiki are available on the project <a href="http://trac.edgewall.org/">Trac</a> site. Source code and distribution files are available at the <a href="http://sourceforge.net/projects/halfcooked">sourceforge page</a>. </p>
<p>The next release will be 0.4. Exactly what will make up that release is still evolving, although it is likely to feature <a href="http://www.microsoft.com/sqlserver/">SQL Server</a> support as I have just started a new job and all of the systems there use it. To see what else is in the release and to track progress take a look at the <a href="https://apps.sourceforge.net/trac/halfcooked/milestone/0.4">version 0.4 roadmap</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://halfcooked.com/blog/2010/02/14/gerald-release-0-3-6/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Weird easy_install Behaviour</title>
		<link>http://halfcooked.com/blog/2010/02/01/weird-easy_install-behaviour/</link>
		<comments>http://halfcooked.com/blog/2010/02/01/weird-easy_install-behaviour/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 05:41:28 +0000</pubDate>
		<dc:creator>Andy Todd</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://halfcooked.com/blog/?p=133</guid>
		<description><![CDATA[Dear lazyweb, I unsubscribed from the distutils-sig mailing list a while back and consequently I&#8217;m not up to date with the latest to-ings and fro-ings. But, I have a problem. As reported by someone today Gerald eggs won&#8217;t install on Windows. Everything is fine on my Ubuntu virtual machine, but on my shiny new work [...]]]></description>
			<content:encoded><![CDATA[<p>Dear lazyweb, I unsubscribed from the <a href="http://mail.python.org/mailman/listinfo/distutils-sig/">distutils-sig mailing list</a> a while back and consequently I&#8217;m not up to date with the latest to-ings and fro-ings. But, I have a problem. As reported by someone today <a href="http://halfcooked.com/code/gerald">Gerald</a> eggs won&#8217;t install on Windows. </p>
<p>Everything is fine on my Ubuntu virtual machine, but on my shiny new work laptop I have Python 2.6 and today I downloaded and installed <a href="http://pypi.python.org/pypi/setuptools">setuptools</a> version 06.c11. When I try and install <a href="http://halfcooked.com/code/gerald">Gerald</a> I get an error complaining about a lack of a <span class="inlinecode">setup.py</span> file;</p>
<pre>
(TEST) C:\Work\virtualenvs\TEST>easy_install gerald
Searching for gerald
Reading http://pypi.python.org/simple/gerald/
Reading http://halfcooked.com/code/gerald/
Reading http://sourceforge.net/project/showfiles.php?group_id=53184&#038;package_id=109623
Reading http://sourceforge.net/projects/halfcooked/files
Best match: gerald 0.3.5
Downloading http://sourceforge.net/projects/halfcooked/files/gerald/0.3.5/gerald-0.3.5-py2.6.egg/download
Processing download
error: Couldn't find a setup script in c:\docume~1\andy~1.tod\locals~1\temp\easy_install-woqly0\download
(TEST) C:\Work\virtualenvs\TEST>
</pre>
<p>The only thing that I can find different is that my Ubuntu virtual machine is running version 0.6c9 of setuptools. Has the function changed between two release candidates? </p>
<p>Needless to say this means that <a href="http://halfcooked.com/code/gerald">Gerald</a> won&#8217;t install under Windows using easy_install until I figure this out. All help and suggestions warmly received.</p>
]]></content:encoded>
			<wfw:commentRss>http://halfcooked.com/blog/2010/02/01/weird-easy_install-behaviour/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

