Being a github polyglot

One of the great presentations at YAPCNA 2012 was Miyagawa’s Becoming a Polyglot. One of the ideas that it brought up was the idea that it was OK to play around in other languages, contribute to said languages, and see what idea you could steal from them or contribute to them. So, it’s been a pleasure to start trying to contribute more to perl projects on github. I think I’ve even found a niche of projects I like to contribute to (GitHub commandline wrappers.)  So, imagine my joy when I saw that today, a new CLI for github had been released.

Octogit is a CLI for github. It’s pretty new and it lets you do lots of neat basic things. It’s written in Python, a language I am absolutely not an expert in, but I can figure it out. So, I checkout out the github repository, clicked on issues, and found one I thought I could attempt. The one that struck my eye was Add command line gist support The fact is that this was a good issue for me to attempt for a number of reasons:

  1. It was similar to existing functionality in the project (listing issues, for example.)
  2. It had a nicely documented REST api (like all of github, really.)
  3. The complexity was low.

So, I forked the repo, and went to town.  The first thing I realized was that I simply didn’t even know how a python project is really structured (that uses setup.py.)  No matter, I simply edited the code, and deployed it to my box using ‘python setup.py install’. I’m sure there is a better way to do this, but I figured that this was going to be the fastest way for me not to get trapped down a rabbit hole of learning, and just solve a problem.

So, I started to figure it out. The cli.py file was the command line parsing, it imported the functions it used at the very top from core.py, and I just needed to add my handling in the appropriate places. Fortunately my instincts were right:

  1. Adding additional command line parsing was templated code from existing command line parsing
  2. Adding additional web service calls was cut/paste
  3. Displaying the additional content was cut/paste

The entire process took at most 30 minutes. It cracks me up however, that in such a short period of time, I learned so very much. I was trying to solve a real actual problem, and I was able to move quickly to do so. The things that I relearned and experienced were:

  1. How indenting works in python
  2. How string interpolation works in python
  3. How throwing / managing exceptions works in python
  4. How the requests library works (it’s so very nice)
  5. How the clint.textui library works
    1. which is awesome
    2. seriously, columns and colored by themselves are amazing
  6. How to open up a browser on my client machine from python

There was so much to learn! And it was awesomely fun.  So, I commited my code and I sent a pull request. I don’t know that it’ll get accepted, it’s possible my code is garbage and I don’t know… But I can now honestly say I have at least attempted to contribute to an open source python project!  Github polyglot, here I come!

Advertisements
This entry was posted in tech and tagged , , , , . Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s