PythonSnippets

Differences between revisions 1 and 2
Revision 1 as of 2010-01-12 02:41:03
Size: 2656
Editor: c-67-164-44-209
Comment:
Revision 2 as of 2010-01-12 02:49:29
Size: 3435
Editor: c-67-164-44-209
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
So right now we have an awesome app for viewing with and playing with snippets, and a means of delivering them to hungry hackers, but what we now need is more snippets. Adding a snippet is as simple as following these steps. Python is a hugely powerful and flexible language for creating compelling applications easily. To make application development on Ubuntu and beyond as easy as posible, the `python-snippets` project has been created to collect together a wide variety of examples as well as a tool called ''Acire'' that can view them, run them and learn from them easily.
Line 5: Line 5:
== Step 1: Grab the library == == Getting and Viewing Python Snippets ==

You can install a daily PPA of Python Snippets and have fresh snippets delivered to you daily. Simply follow these commands to set up the PPA:

{{{
sudo add-apt-repository ppa:python-snippets-drivers/python-snippets-daily
sudo apt-get update
sudo apt-get install python-snippets
}}}

The best way to browse, learn from and use Python Snippets is by using Acire. You can install Acire from its PPA with the following commands:

{{{
sudo add-apt-repository ppa:acire-team/acire-releases
sudo apt-get update
sudo apt-get install acire
}}}


== Submitting a New Snippet ==

=== Step 1: Grab the library ===
Line 13: Line 34:
== Step 2: Create your snippet == === Step 2: Create your snippet ===
Line 18: Line 39:
Step 3: Add metadata
===
Step 3: Add metadata ===
Line 46: Line 68:
== Step 4: Propose it for merging == === Step 4: Propose it for merging ===

Python Snippets

Python is a hugely powerful and flexible language for creating compelling applications easily. To make application development on Ubuntu and beyond as easy as posible, the python-snippets project has been created to collect together a wide variety of examples as well as a tool called Acire that can view them, run them and learn from them easily.

Getting and Viewing Python Snippets

You can install a daily PPA of Python Snippets and have fresh snippets delivered to you daily. Simply follow these commands to set up the PPA:

sudo add-apt-repository ppa:python-snippets-drivers/python-snippets-daily
sudo apt-get update
sudo apt-get install python-snippets

The best way to browse, learn from and use Python Snippets is by using Acire. You can install Acire from its PPA with the following commands:

sudo add-apt-repository ppa:acire-team/acire-releases
sudo apt-get update
sudo apt-get install acire

Submitting a New Snippet

Step 1: Grab the library

Just run:

bzr branch lp:python-snippets

Step 2: Create your snippet

A snippet should demonstrate a specific feature in a given module or in the Python language. This could include showing how to use a specific widget, a feature of that widget, or another function.

python-snippets is divided into sub-directories which outlines the theme of the snippets. You should pick the most appropriate directory to put your snippet it, and add it there. If a suitable directory does not exist already, create it and add it there.

Step 3: Add metadata

The way Acire pulls out the snippets is by detecting some specific metadata additions to comments at the top of the file You should now add the following meta data as comments to the top of the file:

# [SNIPPET_NAME: A Short Name For The Snippet]
# [SNIPPET_CATEGORIES: Category]  <-- see CATEGORIES file for existing categories
# [SNIPPET_DESCRIPTION: A single line description of the snippet]
# [SNIPPET_AUTHOR: Your Name <your@emailaddress.com>]
# [SNIPPET_LICENSE: An Open Source license (from the LICENSES file)]

Here is an example:

# [SNIPPET_NAME: Playing a Pipeline]
# [SNIPPET_CATEGORIES: GStreamer]
# [SNIPPET_DESCRIPTION: Construct and play a pipeline]
# [SNIPPET_AUTHOR: Jono Bacon <jono@ubuntu.com>]
# [SNIPPET_LICENSE: GPL]

You now need to add your file to your branch with:

bzr add your-snippet.py

Step 4: Propose it for merging

With your new snippet ready, it is time to propose it for inclusion in the main python-snippets library.

First, commit your changes to your local branch with:

bzr commit

Now push it to your own branch on Launchpad:

bzr push lp:~<your launchpad username>/python-snippets/<name of your branch>

As an example:

bzr push lp:~jonobacon/python-snippets/gstreamer-snippets

Now go to https://code.launchpad.net/python-snippets and you should see your branch listed there. Click on it and when the branch page information page loads click on the Propose for merging link. Add a short description of what you examples do in the Initial Comment box and then click the Propose Merge button.

We will then review the merge and if it looks good, add it to python-snippets and it will be delivered to Acire users in the next daily package upload. Smile :-)

PythonSnippets (last edited 2010-03-26 04:59:07 by c-67-164-45-120)