| OLD | NEW |
| 1 .. _cds2014_python: | 1 .. _cds2014_python: |
| 2 | 2 |
| 3 ######################################## | 3 ######################################## |
| 4 What a difference Python Makes - Codelab | 4 What a difference Python Makes - Codelab |
| 5 ######################################## | 5 ######################################## |
| 6 | 6 |
| 7 Introduction | 7 Introduction |
| 8 ------------ | 8 ------------ |
| 9 | 9 |
| 10 .. include:: python_summary.inc | 10 .. include:: python_summary.inc |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 Python on the other hand has the |difflib| module in its standard library. | 55 Python on the other hand has the |difflib| module in its standard library. |
| 56 | 56 |
| 57 The starting point you've just extracted contains the shell | 57 The starting point you've just extracted contains the shell |
| 58 of a web app using Portable Native Client Python to generate a diff. | 58 of a web app using Portable Native Client Python to generate a diff. |
| 59 Just one thing is missing, that whole diffing thing... | 59 Just one thing is missing, that whole diffing thing... |
| 60 | 60 |
| 61 To see where things stand, deploy the sample like this:: | 61 To see where things stand, deploy the sample like this:: |
| 62 | 62 |
| 63 make | 63 make |
| 64 | 64 |
| 65 This will copy the sample to /tmp/differ (clobbering whatever is already | 65 This will attempt to open the sample, but will be blocked by |
| 66 there). It will also attempt to open the sample, but will be blocked by | 66 a popup blocker the first time. Click on the URL to accept the popup. |
| 67 a popup blocker. Click on the URL to accept the popup. | 67 It also clobbers /tmp/differ for good measure. |
| 68 | 68 |
| 69 As you can see, this isn't quite what we're going for. | 69 As you can see, this isn't quite what we're going for. |
| 70 | 70 |
| 71 You'll want to modify diff.py, using the editor you selected earlier. | 71 You'll want to modify diff.py, using the editor you selected earlier. |
| 72 You'll probably want to consult the |difflib| documentation. | 72 You'll probably want to consult the |difflib| documentation. |
| 73 I would suggest you check out the HtmlDiff class and make use of | 73 I would suggest you check out the HtmlDiff class and make use of |
| 74 the make_file member function. I would also suggest the splitlines | 74 the make_file member function. Note our goal is to create a |
| 75 full HTML diff, so the make_table function is insufficient. |
| 76 I would also suggest the splitlines |
| 75 function may come in handy. | 77 function may come in handy. |
| 76 | 78 |
| 77 You can test diff.py manually as you would in a normal UNIX environment. | 79 You can test diff.py manually as you would in a normal UNIX environment. |
| 78 It can be run like this:: | 80 It can be run like this:: |
| 79 | 81 |
| 80 ./diff.py before.txt after.txt out.html | 82 ./diff.py before.txt after.txt out.html |
| 81 | 83 |
| 82 Once everything is working diff.html will contain an html diff. | 84 Once everything is working diff.html will contain an html diff. |
| 83 Run `make` again to deploy and test the full app. | 85 After the initial `make` you can hit "Run" to test your changes. |
| 84 | 86 |
| 85 Now get to it, and good luck! | 87 Now get to it, and good luck! |
| 86 | 88 |
| 87 | 89 |
| 88 What you've learned | 90 What you've learned |
| 89 ------------------- | 91 ------------------- |
| 90 | 92 |
| 91 While the details of building and packaging Python have been | 93 While the details of building and packaging Python have been |
| 92 insulated from you for the purpose of this exercise, the key take-home lesson | 94 insulated from you for the purpose of this exercise, the key take-home lesson |
| 93 is how easy it is to leverage Python using PNaCl. | 95 is how easy it is to leverage Python using PNaCl. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 108 `NaCl SDK | 110 `NaCl SDK |
| 109 <https://developer.chrome.com/native-client/sdk/download>`_. | 111 <https://developer.chrome.com/native-client/sdk/download>`_. |
| 110 | 112 |
| 111 For questions, concerns, and help contact us at | 113 For questions, concerns, and help contact us at |
| 112 `native-client-discuss@googlegroups.com | 114 `native-client-discuss@googlegroups.com |
| 113 <https://groups.google.com/forum/#!forum/native-client-discuss>`_. | 115 <https://groups.google.com/forum/#!forum/native-client-discuss>`_. |
| 114 | 116 |
| 115 Bring your interpreted app to PNaCl today! | 117 Bring your interpreted app to PNaCl today! |
| 116 | 118 |
| 117 .. include:: ../nacldev/cleanup_web.inc | 119 .. include:: ../nacldev/cleanup_web.inc |
| OLD | NEW |