I had been away for most of the week as I had to attend a few functions .I managed to get some work done nevertheless. I had to rewrite the jinja template for the webfonts module from scratch and it took more time than expected as I ran into a few problems as I was not very familiar with the plugins to be used and documentation wasn’t very clear either. The templates ui is still a little bit messy.

I am still having problems with font-face syntax as fonts are not getting loaded in chromium and although firefox downloads the fonts, the glyphs are not displayed properly. Lack of errors also makes the bug difficult to fix. My current hypothesis is that the issue has something to do with the mimetypes. It’s available on github.

This week has been a struggle for me mainly due to the lack of error messages. I have been trying to get my version of silpa hosted on openshift without any luck. So it seems like I to read more documentation..

This week I completed the porting of Katapayadi Numbers. So all the modules except for dhwani TTS and webfonts modules have been ported. I tried a hand at porting dhwani, which is written in C with C++ apis. The python module was using CDLL and ctypes to directly use the c binaries. I tried to compile dhwani from source only to get a zlib headers missing error. zlib was already installed in my system and I also checked for zlib.h in /usr/includes. It looks like some tinkering around will be required for getting this to compile. So I decided to try later with a binary and moved on to the webfonts.

Silpa has a webfonts module which provide webfonts for Indian languages which could be easily added to any site by simply linking a url. Since we have moved to flask most of the code had to be rewritten to get this module working. Now multiple fonts can be linked with a single url. I got the dynamic css part working but for some reason the fonts simply are not loading. The webfont module is using @font-face feature to include the fonts and this is good article by Paul Irish on getting it to work across all browsers. I will try to host the site on openshift and try again to make sure the issue is not due to any problem with serving them from localhost.

Also the webfonts module is written in two parts a normal python module which will fit into silpa and the webfonts serving api as a blueprint which allows me to simply attach it to flasks app object either at a urlprefix or a subdomain in a single line of code which is realy usefull. Flask is extremely flexible and you can organize your app as you please.

I ran into some problems with virtualenvs last week and it took a quite a bit of time identifying and fixing the issue. I use powerline with tmux, vim and zsh and it’s realy useful as I work mostly from a terminal and my window manager doesn’t provide a taskbar. Powerline requires $PYTHONPATH to be set explicitly and archlinux comes with python3 as default, this can lead to problem’s with python2 apps. This was a non issue in the beginning as I work inside a virtualenv. However I was working with a module which required cairo and pycairo doesen’t play well with virtualenvs and it was trying to use systems pycairo module. This resulted in my systems python3 sitepackages path getting included in python path of the virtualenvs. Apart from this I also managed to do some permanant damage to my virtualenvs by force installing some packages. After finally figuring out what’s wrong I ended up setting python path in the individual programs confs, nuked .virtualenvwrapper directory and went for a clean install.

So here is the porting tasks current status,

  • TODO dhwani
  • TODO webfonts
  • TODO katapayadi numbers
  • DONE fortune
  • DONE text similarity
  • DONE stemmer
  • DONE shingling
  • DONE sort
  • DONE complex script rendere
  • DONE approxsearch
  • DONE dictionary
  • DONE guesslang
  • DONE payyans
  • DONE spellcheck
  • DONE transliterate
  • DONE hyphenate
  • DONE syllabalize
  • DONE ngram
  • DONE soundex
  • DONE chardetails

I have got the basic python packages and templates for the above modules, I still have to write unit tests, write proper documentation and go through the templates once again so that everything is consistent.Also I have to decide on names so that these can be released on pypi.

Coding period started on 17th and today is 25th and that calls for an update. I have discussed with my Mentor to reorganize the work differently from my proposal. Earlier I was planning to write the tests together with the modules (TDD). I thought it would be better if I do most of the testing and documentation to the last month of the programme as I want to spend moretime on porting tasks.

So progress till now:

Separation of templates

I used jinja2’s choice loader and package loader methods to look for templates in the templates folder of each of the individual packages and load them if there is no corresponding template in the templates folder of the main app. There is very good blog post about how to do this. And flask is one of most well documented projects around and people at #pocoo were very helpful and I got this implemented without much trouble.

Packaging

This has been a very informative task for me as I got to read a lot of kntresting stuff like this and this. It seems python community is still confused about what to use for packaging as the options are plentiful. Distribute, distutils, setuptools and a lot of forking and merging. Silpa has been using setuptools with the neat setuptools-git extension which packages all the git tracked files into your package.

Fixing broken packages and PEP8

I also fixing some of the broken packages and doing some code cleaning to make them PEP8 compaliant.

New packages

I have ported syllabalizer and ngrams packages from silpa into their individual packages. You can find them here: syllabalizer , ngrams (templates included).

What’s next ?

  • port remaining modules starting with guesslanguage
  • fix broken hyphenation module

So I have been using virtualenv and virtualenvwrapper for managing python packages.If you are moving around in your directory tree it realy gets annoying if you have to activate the virtualenv everytime you openup a new tmuz pane or a terminal window.I have switched to zsh recently and just discovered a feature to automate this.Just simply put this in your .zshrc.

function chpwd(){
emulate  zsh
if [ -e ".venv" ]; then
    # Check to see if already activated to avoid redundant activating
    if [ "$VIRTUAL_ENV" != "$VIRTUALENVWRAPPER_HOOK_DIR/`cat .venv`" ]; then
        _VENV_NAME=`cat .venv`
        echo Activating virtualenv $_VENV_NAME
        workon $_VENV_NAME
    fi
fi
}

You have to create a .venv file in your working directory with name of the virtualenv in it to make use of this.There are plenty of similar solutions even if you don’t use zsh (which you should)

I have been meaning to pick up emacs and thought of giving it a try. Even for a new user, emacs looks damn cool.I have heard of emacs being a good os and a bad text editor.After a couple of weeks of and on usage I have to agree.Running a terminal, irc client,mail reader,terminal inside a buffer is cool.But if feel I was more productive after using vim for a shorter period of time.

Emacs doesn’t have text objects

My favourite feature in vim are text objects and they instantly justified my effort in learning vim.Text objects together with vim-surround plugin instantly improves your editing speed if you are working with html or xml. Emacs doesn’t have that by default.Installing a plugin for that functionality wasn’t very appealing to me.

Emacsrocks

I happened to watch a couple of videos at emacs rocks and oh was I impressed! Emacs can be efficient as vim but it seems like I need to memorize quite a bit more.I am not giving up hope, may be one day I will get good with emacs.Living inside a text editor doesn’t sound too bad.

Google Summer of Code 2013

One more attempt at blogging and I will probably continue with this at least for this summer. My proposal for this years Google Summer of Code got through and I will be writing code for Swathanthra Malayalam Computing this summer. SMC is community of open source enthusiasts interested in creating software for people to use in their language of choice. They maintain font repositories and take part in i18n of popular software as well as maintain a few projects such as SILPA, Dhwani TTS and also provide an indic webfonts service. For a full list of their activities do visit their site.

My proposal was to complete the porting of SILPA, the language processing package into a more modular structure using the flask micro web framework written in python. Jishnu Mohan is my alloted mentor for the project with Vasudev Kammath (aka copyninja) and Santhosh Thotingal acting as a secondary mentor.They are the current maintainers of the project which aims to bring language processing tools for indic languages.

The community bonding period started on 28th May and I am supposed to read the documentation and go through the source code and interact with the community members till the coding period kicks off at 21st of June.For the last two weeks I have been idling on #pocoo on freenode (these guys made flask, jinja2 and a lot of other cool python projects) and the people there seemed to be really cool and are helpful to n00bs.I have been looking at some python packaging tools, unittesting frameworks and PEP recommendations for packaging.SILPA is currently using setup tools, with the setup-tools-git extension which adds all the git tracked files into the python package without the need of any fiddling around in the MANIFEST.in file.I will be using pythons built in unittest framework, unittest to write tests for this project.I had taken edX’s SaaS class last semester,(which is a very good course, very challenging if you don’t know ruby, like me when I took the course) where I heard a lot about Test Driven Development and hope to follow some good coding practices for this project.

I have made some prototypes for the proposed template separation and hope to hit the road running when the coding period starts.Till then more code reading to get familiar with all the modules of silpa. Since I have a little time on my hands now, I have some spring cleaning to do(or rather summer cleaning or formatting my archlinux system, a new .vimrc and a new playlist).I have learnt a lot as a developper during the gsoc application period and I am sure I will learn even more.That’s it for now, the talk is done, next time there will be some code to show.

Talk is cheap. Show me the code. Torvalds, Linus (2000-08-25). Message to linux-kernel mailing list. Retrieved on 2006-08-28.