summaryrefslogtreecommitdiff
path: root/docs/pycon2010
diff options
context:
space:
mode:
authorCatherine Devlin <catherine.devlin@gmail.com>2010-02-16 11:02:56 -0500
committerCatherine Devlin <catherine.devlin@gmail.com>2010-02-16 11:02:56 -0500
commita9ec4048ab97c011d95b0529ee483556c663ccae (patch)
treea999e16d9bc2f6f7b396fa5c5b9f74113599bfda /docs/pycon2010
parentbd70238db3a33bb3afe6887fa81461860ec061d5 (diff)
downloadcmd2-git-a9ec4048ab97c011d95b0529ee483556c663ccae.tar.gz
begin Pycon talk
Diffstat (limited to 'docs/pycon2010')
-rw-r--r--docs/pycon2010/apple.jpgbin0 -> 72215 bytes
-rw-r--r--docs/pycon2010/pirate.py7
-rw-r--r--docs/pycon2010/pirate2.py16
-rw-r--r--docs/pycon2010/pirate3.py16
-rw-r--r--docs/pycon2010/pirate4.py23
-rw-r--r--docs/pycon2010/pirate5.py30
-rw-r--r--docs/pycon2010/pirate6.py33
-rw-r--r--docs/pycon2010/pycon2010.rst98
-rw-r--r--docs/pycon2010/sargon.jpgbin0 -> 17452 bytes
-rw-r--r--docs/pycon2010/urwid.pngbin0 -> 40788 bytes
-rw-r--r--docs/pycon2010/web-2-0-logos.gifbin0 -> 55776 bytes
11 files changed, 223 insertions, 0 deletions
diff --git a/docs/pycon2010/apple.jpg b/docs/pycon2010/apple.jpg
new file mode 100644
index 00000000..2148af3b
--- /dev/null
+++ b/docs/pycon2010/apple.jpg
Binary files differ
diff --git a/docs/pycon2010/pirate.py b/docs/pycon2010/pirate.py
new file mode 100644
index 00000000..98db50ea
--- /dev/null
+++ b/docs/pycon2010/pirate.py
@@ -0,0 +1,7 @@
+from cmd import Cmd
+
+class Pirate(Cmd):
+ pass
+
+pirate = Pirate()
+pirate.cmdloop() \ No newline at end of file
diff --git a/docs/pycon2010/pirate2.py b/docs/pycon2010/pirate2.py
new file mode 100644
index 00000000..65c711a3
--- /dev/null
+++ b/docs/pycon2010/pirate2.py
@@ -0,0 +1,16 @@
+from cmd import Cmd
+# using ``do_`` methods
+
+class Pirate(Cmd):
+ gold = 10
+ def do_loot(self, arg):
+ 'Seize booty frrrom a passing ship.'
+ self.gold += 1
+ print 'Now we gots {0} doubloons'.format(self.gold)
+ def do_drink(self, arg):
+ 'Drown your sorrrows in rrrum.'
+ self.gold -= 1
+ print 'Now we gots {0} doubloons'.format(self.gold)
+
+pirate = Pirate()
+pirate.cmdloop() \ No newline at end of file
diff --git a/docs/pycon2010/pirate3.py b/docs/pycon2010/pirate3.py
new file mode 100644
index 00000000..a56b03f6
--- /dev/null
+++ b/docs/pycon2010/pirate3.py
@@ -0,0 +1,16 @@
+from cmd import Cmd
+# using a hook
+
+class Pirate(Cmd):
+ gold = 3
+ def do_loot(self, arg):
+ 'Drown your sorrrows in rrrum.'
+ self.gold += 1
+ def do_drink(self, arg):
+ 'Drown your sorrrows in rrrum.'
+ self.gold -= 1
+ def postcmd(self, stop, line):
+ print 'Now we gots {0} doubloons'.format(self.gold)
+
+pirate = Pirate()
+pirate.cmdloop() \ No newline at end of file
diff --git a/docs/pycon2010/pirate4.py b/docs/pycon2010/pirate4.py
new file mode 100644
index 00000000..d8b83e1c
--- /dev/null
+++ b/docs/pycon2010/pirate4.py
@@ -0,0 +1,23 @@
+from cmd import Cmd
+# using arguments
+
+class Pirate(Cmd):
+ gold = 3
+ def do_loot(self, arg):
+ 'Drown your sorrrows in rrrum.'
+ self.gold += 1
+ def do_drink(self, arg):
+ '''Drown your sorrrows in rrrum.
+
+ drink [n] - drink [n] barrel[s] o' rum.'''
+ try:
+ self.gold -= int(arg)
+ except:
+ if arg:
+ print '''What's "{0}"? I'll take rrrum.'''.format(arg)
+ self.gold -= 1
+ def postcmd(self, stop, line):
+ print 'Now we gots {0} doubloons'.format(self.gold)
+
+pirate = Pirate()
+pirate.cmdloop() \ No newline at end of file
diff --git a/docs/pycon2010/pirate5.py b/docs/pycon2010/pirate5.py
new file mode 100644
index 00000000..5e70cff2
--- /dev/null
+++ b/docs/pycon2010/pirate5.py
@@ -0,0 +1,30 @@
+from cmd import Cmd
+# quitting
+
+class Pirate(Cmd):
+ gold = 3
+ def do_loot(self, arg):
+ 'Drown your sorrrows in rrrum.'
+ self.gold += 1
+ def do_drink(self, arg):
+ '''Drown your sorrrows in rrrum.
+
+ drink [n] - drink [n] barrel[s] o' rum.'''
+ try:
+ self.gold -= int(arg)
+ except:
+ if arg:
+ print '''What's "{0}"? I'll take rrrum.'''.format(arg)
+ self.gold -= 1
+ def postcmd(self, stop, line):
+ print 'Now we gots {0} doubloons'.format(self.gold)
+ if self.gold < 0:
+ print "Off to debtorrr's prrrison. Game overrr."
+ return True
+ return stop
+ def do_quit(self, arg):
+ print "Quiterrr!"
+ return True
+
+pirate = Pirate()
+pirate.cmdloop() \ No newline at end of file
diff --git a/docs/pycon2010/pirate6.py b/docs/pycon2010/pirate6.py
new file mode 100644
index 00000000..8ae0bdfa
--- /dev/null
+++ b/docs/pycon2010/pirate6.py
@@ -0,0 +1,33 @@
+from cmd2 import Cmd
+# prompts and defaults
+
+class Pirate(Cmd):
+ gold = 3
+ prompt = 'arrr> '
+ def default(self, line):
+ print 'What mean ye by "{0}"?'.format(line)
+ def do_loot(self, arg):
+ 'Drown your sorrrows in rrrum.'
+ self.gold += 1
+ def do_drink(self, arg):
+ '''Drown your sorrrows in rrrum.
+
+ drink [n] - drink [n] barrel[s] o' rum.'''
+ try:
+ self.gold -= int(arg)
+ except:
+ if arg:
+ print '''What's "{0}"? I'll take rrrum.'''.format(arg)
+ self.gold -= 1
+ def postcmd(self, stop, line):
+ print 'Now we gots {0} doubloons'.format(self.gold)
+ if self.gold < 0:
+ print "Off to debtorrr's prrrison. Game overrr."
+ return True
+ return stop
+ def do_quit(self, arg):
+ print "Quiterrr!"
+ return True
+
+pirate = Pirate()
+pirate.cmdloop() \ No newline at end of file
diff --git a/docs/pycon2010/pycon2010.rst b/docs/pycon2010/pycon2010.rst
new file mode 100644
index 00000000..800e3eb8
--- /dev/null
+++ b/docs/pycon2010/pycon2010.rst
@@ -0,0 +1,98 @@
+py 3
+
+Web 2.0
+=======
+
+.. image:: web-2-0-logos.gif
+ :height: 300 px
+
+But first...
+============
+
+.. image:: sargon.jpg
+ :height: 300 px
+
+Sargon the Great founded the Akkadian Empire
+in the twenty-third century BC.
+
+In between
+==========
+
+.. image:: apple.jpg
+ :height: 300 px
+
+Unlike the Akkadian Empire, the CLI will never disappear.
+
+line-oriented command interpreter
+command-line interface
+text user interface
+terminal user interface
+console
+shell
+
+Defining
+========
+
+Prompt accepts free text input
+Outputs lines of text
+CLI environment persists
+
+Examples
+========
+
+Bash, Korn, zsh
+Python shell
+screen
+Zork
+ed
+SQL clients: psql, SQL*\Plus, mysql...
+
+!= Command Line Utilities
+=========================
+
+Accept single set of arguments at
+invocation, execute, terminate
+
+dir
+grep
+ping
+
+sys.argv
+optparse
+
+!= Text User Interfaces
+=======================
+
+("console")
+
+Use entire (session) screen
+Not line-by-line
+
+.. image:: urwid.png
+ :height: 300px
+
+curses
+urwid
+
+
+foo a b c ->
+self.do_foo('a b c')
+self.default('foo a b c')
+
+pirate.py
+=========
+
+::
+
+ from cmd import Cmd
+
+ class Pirate(Cmd):
+ pass
+
+ pirate = Pirate()
+ pirate.cmdloop()
+
+history: cursor
+ctrl-r
+help
+
diff --git a/docs/pycon2010/sargon.jpg b/docs/pycon2010/sargon.jpg
new file mode 100644
index 00000000..5960f1e0
--- /dev/null
+++ b/docs/pycon2010/sargon.jpg
Binary files differ
diff --git a/docs/pycon2010/urwid.png b/docs/pycon2010/urwid.png
new file mode 100644
index 00000000..c2b5a9bf
--- /dev/null
+++ b/docs/pycon2010/urwid.png
Binary files differ
diff --git a/docs/pycon2010/web-2-0-logos.gif b/docs/pycon2010/web-2-0-logos.gif
new file mode 100644
index 00000000..9d48e37d
--- /dev/null
+++ b/docs/pycon2010/web-2-0-logos.gif
Binary files differ