Index: native_client_sdk/src/doc/cds2014/python.rst |
diff --git a/native_client_sdk/src/doc/cds2014/python.rst b/native_client_sdk/src/doc/cds2014/python.rst |
new file mode 100644 |
index 0000000000000000000000000000000000000000..bc4b5d21224badcd090d69ea637bd5f4b9e9bf5c |
--- /dev/null |
+++ b/native_client_sdk/src/doc/cds2014/python.rst |
@@ -0,0 +1,117 @@ |
+.. _cds2014_python: |
+ |
+######################################## |
+What a difference Python Makes - Codelab |
+######################################## |
+ |
+Introduction |
+------------ |
+ |
+.. include:: python_summary.inc |
+ |
+.. include:: ../nacldev/setup_web.inc |
+ |
+ |
+Get the Code! |
+------------- |
+ |
+Rather than start from nothing, for this codelab we've provided |
+you with a zip file containing a starting point. |
+ |
+Download the codelab:: |
+ |
+ geturl https://nacltools.storage.googleapis.com/cds2014/cds2014_python.zip cds2014_python.zip |
+ |
+Unzip it:: |
+ |
+ unzip cds2014_python.zip |
+ |
+Go into the codelab directory:: |
+ |
+ cd cds2014_python |
+ |
+Create a new local git repo:: |
+ |
+ git init |
+ |
+Add everything:: |
+ |
+ git add . |
+ |
+Commit it:: |
+ |
+ git commit -am "initial" |
+ |
+While working, you can see what you've changed by running:: |
+ |
+ git diff |
+ |
+ |
+Your challenge, should you choose to accept it... |
+------------------------------------------------- |
+ |
+Javascript has many wonderful features out of the box. |
+Unfortunately, generating textual diffs is not one of them. |
+Python on the other hand has the |difflib| module in its standard library. |
+ |
+The starting point you've just extracted contains the shell |
+of a web app using Portable Native Client Python to generate a diff. |
+Just one thing is missing, that whole diffing thing... |
+ |
+To see where things stand, deploy the sample like this:: |
+ |
+ make |
+ |
+This will copy the sample to /tmp/differ (clobbering whatever is already |
+there). It will also attempt to open the sample, but will be blocked by |
+a popup blocker. Click on the URL to accept the popup. |
+ |
+As you can see, this isn't quite what we're going for. |
+ |
+You'll want to modify diff.py, using the editor you selected earlier. |
+You'll probably want to consult the |difflib| documentation. |
+I would suggest you check out the HtmlDiff class and make use of |
+the make_file member function. I would also suggest the splitlines |
+function may come in handy. |
+ |
+You can test diff.py manually as you would in a normal UNIX environment. |
+It can be run like this:: |
+ |
+ ./diff.py before.txt after.txt out.html |
+ |
+Once everything is working diff.html will contain an html diff. |
+Run `make` again to deploy and test the full app. |
+ |
+Now get to it, and good luck! |
+ |
+ |
+What you've learned |
+------------------- |
+ |
+While the details of building and packaging Python have been |
+insulated from you for the purpose of this exercise, the key take-home lesson |
+is how easy it is to leverage Python using PNaCl. |
+As you've likely experienced, the initial start time is non-trivial. |
+We're working on improving this, both by improving PNaCl, |
+and our Python port. |
+ |
+The same approach to deploying Python apps can be used for the other |
+interpreted languages that have been ported to PNaCl. |
+ |
+Check out the range of interpreters, libraries, and tools |
+`already ported to PNaCl and ready to be integrated with your Web App |
+<https://code.google.com/p/naclports/wiki/PortList>`_. |
+ |
+While our in-browser environment is rapidly evolving |
+to become a complete development solution, |
+for the broadest range of development options, check out the |
+`NaCl SDK |
+<https://developer.chrome.com/native-client/sdk/download>`_. |
+ |
+For questions, concerns, and help contact us at |
+`native-client-discuss@googlegroups.com |
+<https://groups.google.com/forum/#!forum/native-client-discuss>`_. |
+ |
+Bring your interpreted app to PNaCl today! |
+ |
+.. include:: ../nacldev/cleanup_web.inc |