annotate textshaper/commands.py @ 33:de3148412191

STUB: textshaper/commands.py
author Jeff Hammel <k0scist@gmail.com>
date Sun, 23 Feb 2014 16:48:09 -0800
parents
children 88a69d587326
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
33
de3148412191 STUB: textshaper/commands.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
de3148412191 STUB: textshaper/commands.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
de3148412191 STUB: textshaper/commands.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
3
de3148412191 STUB: textshaper/commands.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
4 """
de3148412191 STUB: textshaper/commands.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
5 CLI commands for textshaper
de3148412191 STUB: textshaper/commands.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
6 """
de3148412191 STUB: textshaper/commands.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
7
de3148412191 STUB: textshaper/commands.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
8 class Shaper(object):
de3148412191 STUB: textshaper/commands.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
9 """individual text shaper component"""
de3148412191 STUB: textshaper/commands.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
10
de3148412191 STUB: textshaper/commands.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
11 def __init__(self, function):
de3148412191 STUB: textshaper/commands.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
12 self.function = function
de3148412191 STUB: textshaper/commands.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
13
de3148412191 STUB: textshaper/commands.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
14 class Commands(object):
de3148412191 STUB: textshaper/commands.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
15
de3148412191 STUB: textshaper/commands.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
16 def __init__(self):
de3148412191 STUB: textshaper/commands.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
17 self.shapers = []
de3148412191 STUB: textshaper/commands.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
18 self.keys = {}
de3148412191 STUB: textshaper/commands.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
19
de3148412191 STUB: textshaper/commands.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
20 def add(self, function, key=None):
de3148412191 STUB: textshaper/commands.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
21 self.shapers.append(Shaper(function))
de3148412191 STUB: textshaper/commands.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
22 if key:
de3148412191 STUB: textshaper/commands.py
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
23 self.keys[key] = self.shapers[-1]