Mercurial > piecrust2
annotate piecrust/commands/base.py @ 2:40fa08b261b9
Added unit tests (using `py.test`) for `Configuration`.
Fixed some configuration module bugs.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 25 Dec 2013 22:16:46 -0800 |
parents | aaa8fb7c8918 |
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 |