Mercurial > piecrust2
annotate piecrust/commands/base.py @ 1:aaa8fb7c8918
Re-arranged modules to reduce dependencies to builtin stuff.
Added `init` command.
| author | Ludovic Chabant <ludovic@chabant.com> |
|---|---|
| date | Sun, 22 Dec 2013 08:00:24 -0800 |
| parents | a212a3f2e3ee |
| children | f485ba500df3 |
| rev | line source |
|---|---|
| 0 | 1 import logging |
|
1
aaa8fb7c8918
Re-arranged modules to reduce dependencies to builtin stuff.
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
2 from piecrust.pathutil import SiteNotFoundError |
| 0 | 3 |
| 4 | |
| 5 logger = logging.getLogger(__name__) | |
| 6 | |
| 7 | |
| 8 class CommandContext(object): | |
|
1
aaa8fb7c8918
Re-arranged modules to reduce dependencies to builtin stuff.
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
9 def __init__(self, app, args): |
|
aaa8fb7c8918
Re-arranged modules to reduce dependencies to builtin stuff.
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
10 self.app = app |
| 0 | 11 self.args = args |
| 12 | |
| 13 | |
| 14 class ChefCommand(object): | |
| 15 def __init__(self): | |
| 16 self.name = '__unknown__' | |
| 17 self.description = '__unknown__' | |
| 18 self.requires_website = True | |
| 19 | |
| 20 def setupParser(self, parser): | |
| 21 raise NotImplementedError() | |
| 22 | |
| 23 def run(self, ctx): | |
| 24 raise NotImplementedError() | |
| 25 | |
|
1
aaa8fb7c8918
Re-arranged modules to reduce dependencies to builtin stuff.
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
26 def _runFromChef(self, app, res): |
|
aaa8fb7c8918
Re-arranged modules to reduce dependencies to builtin stuff.
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
27 if app.root is None and self.requires_website: |
|
aaa8fb7c8918
Re-arranged modules to reduce dependencies to builtin stuff.
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
28 raise SiteNotFoundError() |
|
aaa8fb7c8918
Re-arranged modules to reduce dependencies to builtin stuff.
Ludovic Chabant <ludovic@chabant.com>
parents:
0
diff
changeset
|
29 self.run(CommandContext(app, res)) |
| 0 | 30 |
