Category Archives: Python

Sky Explorer Supports Unicode Filename

Unicode filename and path are supported in version 1.0.3
The symbian python os functions can accept utf8 string and will also return utf8 string (eg. in os.listdir). It does not use unicode string like in other native symbian functions.
Since the Sky Explorer code uses path.join to get the full path in a lot of places, I [...]

SimCity Goes Open Source as Micropolis

From ars technica.
Will Wright’s original SimCity has now gone open-source under the GNU General Public License. Though the name and some code have been changed due to EA’s requirements, the core of the title remains intact and is now open for the public. This follows the inclusion of SimCity into the OLPC project.
Originally written in [...]

Python Script to Import Simple Tagging tags to Wordpress 2.3

Wordpress 2.3 database now supports tags. For some reason, the Wordpress importer for Simple Tagging doesn’t work for me, it imports only halfway.
I wrote this python script stp-import.py to import the tags to Wordpress 2.3 database.
[~]$ python stp-import.py
The script will ask for the Wordpress database name, the database user and password, and the Wordpress database [...]

Testing FAM with Python

There is a Python module python-fam that uses the client lib of FAM.
There is segmentation fault on deletion of python FAM obj, which can be checked using GDB. After replacing the code PyMem_DEL with PyObject_Del in _fam.c and rebuilt the extension, the segmentation fault goes away. (I submit this as a bug?)
Here is the test [...]

Showing Digg Popular Stories

Digg Popular Stories are now shown at the bottom of some of the categories and browse tag pages.
The categories include Diversion, Game, Science, Sports, Technology, World, Php and Python. The tags include Astronomy, environment, nba, php, python, Microsoft and video.
I wrote python scripts to retrieve the popular stories provided by Digg api and format the [...]

Stringtemplate With Dict Data

There seems to be a bug if the dict has a value of an empty string.

def test_templateEmpStr():
import stringtemplate
st = stringtemplate.StringTemplate(”empty:$s$ok”)
st['s'] = ” #None,” ok
print str(st)
st = stringtemplate.StringTemplate(”empty:$m.s$ok”)
st['m'] = {’s’: ”}
[...]

Stringtemplate Unicode Renderer

The stringtemplate library is a port of java template engine StringTemplate. The python stringtemplate documentation.
The default string rendering of the library doesn’t handle unicode string. Below describes how I handle it.

import stringtemplate

class UnicodeStrRenderer(stringtemplate.AttributeRenderer):
def __init__(self):
pass
def str(self, o):
[...]