Mercurial > piecrust2
comparison piecrust/importing/base.py @ 297:2823ea40cfac
import: Put importer metadata on the class, and allow return values.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 10 Mar 2015 08:34:45 -0700 |
parents | 28958565a17b |
children | 2daa05a21026 |
comparison
equal
deleted
inserted
replaced
296:efdefe34ec89 | 297:2823ea40cfac |
---|---|
7 | 7 |
8 logger = logging.getLogger(__name__) | 8 logger = logging.getLogger(__name__) |
9 | 9 |
10 | 10 |
11 class Importer(object): | 11 class Importer(object): |
12 def __init__(self): | 12 name = None |
13 self.name = None | 13 description = None |
14 self.description = None | 14 requires_website = True |
15 self.requires_website = True | |
16 | 15 |
17 def setupParser(self, parser, app): | 16 def setupParser(self, parser, app): |
18 raise NotImplementedError() | 17 raise NotImplementedError() |
19 | 18 |
20 def importWebsite(self, app, args): | 19 def importWebsite(self, app, args): |
21 raise NotImplementedError() | 20 raise NotImplementedError() |
22 | 21 |
23 def checkedImportWebsite(self, ctx): | 22 def checkedImportWebsite(self, ctx): |
24 if ctx.app.root_dir is None and self.requires_website: | 23 if ctx.app.root_dir is None and self.requires_website: |
25 raise SiteNotFoundError() | 24 raise SiteNotFoundError() |
26 self.importWebsite(ctx.app, ctx.args) | 25 return self.importWebsite(ctx.app, ctx.args) |
27 return 0 | |
28 | 26 |
29 | 27 |
30 class FileWalkingImporter(Importer): | 28 class FileWalkingImporter(Importer): |
31 def setupParser(self, parser, app): | 29 def setupParser(self, parser, app): |
32 parser.add_argument('--exclude', nargs='+', | 30 parser.add_argument('--exclude', nargs='+', |