comparison docs/pycon2010/pycon2010.rst @ 372:bf314710e64b

can't make theme work
author cat@eee
date Fri, 19 Feb 2010 00:23:18 -0500
parents 40cba30b6125
children a381f8dd3a45
comparison
equal deleted inserted replaced
371:e84703583996 372:bf314710e64b
13 13
14 Web 2.0 14 Web 2.0
15 ======= 15 =======
16 16
17 .. image:: web-2-0-logos.gif 17 .. image:: web-2-0-logos.gif
18 :height: 250px 18 :height: 350px
19 19
20 But first... 20 But first...
21 ============ 21 ============
22 22
23 .. image:: sargon.jpg 23 .. image:: sargon.jpg
41 Unlike the Akkadian Empire, 41 Unlike the Akkadian Empire,
42 the CLI will never die. 42 the CLI will never die.
43 43
44 Defining CLI 44 Defining CLI
45 ============ 45 ============
46
47 Also known as
46 48
47 - "Line-oriented command interpreter" 49 - "Line-oriented command interpreter"
48 - "Command-line interface" 50 - "Command-line interface"
49 - "Shell" 51 - "Shell"
50 52
73 2. executes 75 2. executes
74 3. terminates 76 3. terminates
75 77
76 Use ``sys.argv``, ``optparse`` 78 Use ``sys.argv``, ``optparse``
77 79
78 != "Text User Interfaces", "Consoles" 80 !="Text User Interface", "Console"
79 ===================================== 81 ==================================
80 82
81 * Use entire (session) screen 83 * Use entire (session) screen
82 * I/O is *not* line-by-line 84 * I/O is *not* line-by-line
85 * See ``curses``, ``urwid``
83 86
84 .. image:: urwid.png 87 .. image:: urwid.png
85 :height: 250px 88 :height: 250px
86 89
87 Use ``curses``, ``urwid`` 90
88 91 Decide your priorities
89 Priorities 92 ======================
90 ==========
91 93
92 .. image:: strategy.png 94 .. image:: strategy.png
93 :height: 250px 95 :height: 350px
94 96
95 A ``cmd`` app: pirate.py 97 A ``cmd`` app: pirate.py
96 ======================== 98 ========================
97 99
98 :: 100 ::
111 113
112 Fundamental prrrinciple 114 Fundamental prrrinciple
113 ======================= 115 =======================
114 116
115 .. class:: huge 117 .. class:: huge
116
117 ::
118 118
119 (Cmd) foo a b c 119 Transform ``(Cmd) foo a b c``
120 120
121 ``self.do_foo('a b c')`` 121 to ``self.do_foo('a b c')``
122 122
123 ``do_``-methods: pirate2.py 123 ``do_``-methods: pirate2.py
124 =========================== 124 ===========================
125 125
126 :: 126 ::
204 204
205 prompt = 'arrr> ' 205 prompt = 'arrr> '
206 def default(self, line): 206 def default(self, line):
207 print('What mean ye by "{0}"?' 207 print('What mean ye by "{0}"?'
208 .format(line)) 208 .format(line))
209 209
210 Other CLI packages
211 ==================
212
213 * cmdlin
214 * cmd2
215
216 Demo
217 ====
218
219 Convert ``cmd`` app to ``cmd2``
220
210 cmd2 221 cmd2
211 ==== 222 ====
212 223
213 .. image:: schematic.png 224 .. image:: schematic.png
214 :height: 250px 225 :height: 350px
215 226
216 Absolutely free 227 Absolutely free
217 =============== 228 ===============
218 229
219 * Script files 230 * Script files
266 Options: pirate8.py 277 Options: pirate8.py
267 =================== 278 ===================
268 279
269 :: 280 ::
270 281
271 @options([make_option('--ho', type='int', help="How often to chant 'ho'", default=2),
272 make_option('-c', '--commas', action="store_true", help="Interspers commas")])
273 def do_yo(self, arg, opts): 282 def do_yo(self, arg, opts):
274 chant = ['yo'] + ['ho'] * opts.ho 283 chant = ['yo'] + ['ho'] * opts.ho
275 if opts.commas: 284 separator = ', ' if opts.commas else ' '
276 separator = ', '
277 else:
278 separator = ' '
279 chant = separator.join(chant) 285 chant = separator.join(chant)
280 print('{0} and a bottle of {1}'.format(chant, arg)) 286 print('{0} and a bottle of {1}'
287 .format(chant, arg))
281 288
282 Serious example: sqlpython 289 Serious example: sqlpython
283 ========================== 290 ==========================
284 291
285 ``cmd``-based app by Luca Canali @ CERN 292 ``cmd``-based app by Luca Canali @ CERN
289 Now ``cmd2``-based; postgreSQL; MySQL 296 Now ``cmd2``-based; postgreSQL; MySQL
290 297
291 sqlpython features 298 sqlpython features
292 ================== 299 ==================
293 300
294 Everything in ``cmd2`` 301 * from ``cmd2``: scripts, redirection,
295 (scripts, redirection, py) 302 py, etc.
296 303 * multiple connections
297 Multi connections 304 * UNIX: ls, cat, grep
298 305 * Special output
299 ls, grep 306
300 307 File reporter
301 Output to html, csv, inserts, bar graphs 308 =============
302 309
303 py session with bind variables 310 Gather info: Python
304 311
305 312 Store: postgresql
306 313
307 314 Report: html
315
316 Thank you
317 =========
318
319 pypi.
320
321 catherinedevlin.blogspot.com
322
323 catherinedevlin.pythoneers.com
324
325